summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLemonBoy <thatlemon@gmail.com>2022-05-14 18:10:15 +0100
committerBram Moolenaar <Bram@vim.org>2022-05-14 18:10:15 +0100
commit698cb4c8fa16a4dbe4830648532c09d7e5c89095 (patch)
tree5ed59c30e81410dee01bc4de72241dfe7ce700d4
parent30ab04e16e1e9e6133590181197b3f8e70cb495e (diff)
downloadvim-git-698cb4c8fa16a4dbe4830648532c09d7e5c89095.tar.gz
patch 8.2.4954: inserting line breaks text property spanning two linesv8.2.4954
Problem: Inserting line breaks text property spanning more then one line. Solution: Check TP_FLAG_CONT_PREV and TP_FLAG_CONT_NEXT. (closes #10423)
-rw-r--r--src/testdir/test_textprop.vim33
-rw-r--r--src/textprop.c9
-rw-r--r--src/version.c2
3 files changed, 40 insertions, 4 deletions
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim
index e2988664b..a2ba477e7 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -1958,4 +1958,37 @@ func Test_prop_shift_block()
bwipe!
endfunc
+func Test_prop_insert_multiline()
+ new
+ call AddPropTypes()
+
+ call setline(1, ['foobar', 'barbaz'])
+ call prop_add(1, 4, #{end_lnum: 2, end_col: 4, type: 'one'})
+
+ call feedkeys("1Goquxqux\<Esc>", 'nxt')
+ call feedkeys("2GOquxqux\<Esc>", 'nxt')
+
+ let lines =<< trim END
+ foobar
+ quxqux
+ quxqux
+ barbaz
+ END
+ call assert_equal(lines, getline(1, '$'))
+ let expected = [
+ \ {'lnum': 1, 'id': 0, 'col': 4, 'type_bufnr': 0, 'end': 0, 'type': 'one',
+ \ 'length': 4 ,'start': 1},
+ \ {'lnum': 2, 'id': 0, 'col': 1, 'type_bufnr': 0, 'end': 0, 'type': 'one',
+ \ 'length': 7, 'start': 0},
+ \ {'lnum': 3, 'id': 0, 'col': 1, 'type_bufnr': 0, 'end': 0, 'type': 'one',
+ \ 'length': 7, 'start': 0},
+ \ {'lnum': 4, 'id': 0, 'col': 1, 'type_bufnr': 0, 'end': 1, 'type': 'one',
+ \ 'length': 3, 'start': 0}
+ \ ]
+ call assert_equal(expected, prop_list(1, #{end_lnum: 10}))
+
+ call DeletePropTypes()
+ bwipe!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/textprop.c b/src/textprop.c
index 5ec983fcb..6fc628a27 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -1650,11 +1650,12 @@ adjust_prop(
proptype_T *pt = text_prop_type_by_id(curbuf, prop->tp_type);
int start_incl = (pt != NULL
&& (pt->pt_flags & PT_FLAG_INS_START_INCL))
- || (flags & APC_SUBSTITUTE);
+ || (flags & APC_SUBSTITUTE)
+ || (prop->tp_flags & TP_FLAG_CONT_PREV);
int end_incl = (pt != NULL
- && (pt->pt_flags & PT_FLAG_INS_END_INCL));
- // Do not drop zero-width props if they later can increase in
- // size.
+ && (pt->pt_flags & PT_FLAG_INS_END_INCL))
+ || (prop->tp_flags & TP_FLAG_CONT_NEXT);
+ // Do not drop zero-width props if they later can increase in size.
int droppable = !(start_incl || end_incl);
adjustres_T res = {TRUE, FALSE};
diff --git a/src/version.c b/src/version.c
index 81bbdf958..b8712f21e 100644
--- a/src/version.c
+++ b/src/version.c
@@ -747,6 +747,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 4954,
+/**/
4953,
/**/
4952,