summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2021-05-26 22:32:10 +0200
committerBram Moolenaar <Bram@vim.org>2021-05-26 22:32:10 +0200
commit840f91f110c4790a145e76eec453326445290f21 (patch)
treeed4301b3bc07ba662e3226feb36010edc5ca2b9c
parentc512599b22aac7305b171566c2f595e0ae85b885 (diff)
patch 8.2.2890: text property duplicated when data block splitsv8.2.2890
Problem: Text property duplicated when data block splits. Solution: Do not continue text prop from previous line. (closes #8261)
-rw-r--r--src/memline.c9
-rw-r--r--src/structs.h1
-rw-r--r--src/testdir/test_textprop.vim19
-rw-r--r--src/version.c2
4 files changed, 29 insertions, 2 deletions
diff --git a/src/memline.c b/src/memline.c
index 4c4a1b24cb..5356369c16 100644
--- a/src/memline.c
+++ b/src/memline.c
@@ -2772,7 +2772,8 @@ ml_append_int(
len = (colnr_T)STRLEN(line) + 1; // space needed for the text
#ifdef FEAT_PROP_POPUP
- if (curbuf->b_has_textprop && lnum > 0 && !(flags & ML_APPEND_UNDO))
+ if (curbuf->b_has_textprop && lnum > 0
+ && !(flags & (ML_APPEND_UNDO | ML_APPEND_NOPROP)))
// Add text properties that continue from the previous line.
add_text_props_for_append(buf, lnum, &line, &len, &tofree);
#endif
@@ -3992,7 +3993,11 @@ ml_flush_line(buf_T *buf)
*/
// How about handling errors???
(void)ml_append_int(buf, lnum, new_line, new_len,
- (dp->db_index[idx] & DB_MARKED) ? ML_APPEND_MARK : 0);
+ ((dp->db_index[idx] & DB_MARKED) ? ML_APPEND_MARK : 0)
+#ifdef FEAT_PROP_POPUP
+ | ML_APPEND_NOPROP
+#endif
+ );
(void)ml_delete_int(buf, lnum, 0);
}
}
diff --git a/src/structs.h b/src/structs.h
index 3bb641be84..a923a35edc 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -774,6 +774,7 @@ typedef struct memline
#define ML_APPEND_NEW 1 // starting to edit a new file
#define ML_APPEND_MARK 2 // mark the new line
#define ML_APPEND_UNDO 4 // called from undo
+#define ML_APPEND_NOPROP 8 // do not continue textprop from previous line
/*
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim
index efa31f0a0a..d1e8f38d49 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -1469,5 +1469,24 @@ func Test_prop_one_line_window()
bwipe!
endfunc
+" This was calling ml_append_int() and copy a text property from a previous
+" line at the wrong moment. Exact text length matters.
+def Test_prop_splits_data_block()
+ new
+ var lines: list<string> = [repeat('x', 35)]->repeat(41)
+ + [repeat('!', 35)]
+ + [repeat('x', 35)]->repeat(56)
+ lines->setline(1)
+ prop_type_add('someprop', {highlight: 'ErrorMsg'})
+ prop_add(1, 27, {end_lnum: 1, end_col: 70, type: 'someprop'})
+ prop_remove({type: 'someprop'}, 1)
+ prop_add(35, 22, {end_lnum: 43, end_col: 43, type: 'someprop'})
+ prop_remove({type: 'someprop'}, 35, 43)
+ assert_equal([], prop_list(42))
+
+ bwipe!
+ prop_type_delete('someprop')
+enddef
+
" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/version.c b/src/version.c
index 56f0f0b946..e61edc6a31 100644
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2890,
+/**/
2889,
/**/
2888,