summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-11-16 20:41:51 +0100
committerBram Moolenaar <Bram@vim.org>2019-11-16 20:41:51 +0100
commitecafcc15ca92ecb9c6b41dbb3b0fcdf89c9eff69 (patch)
treec9b4e5ecf302b46bfa77fa64cf242932df84e080
parenta37cb55da6ba44c5e85a22b03a91e1b663aceddf (diff)
patch 8.1.2308: deleting text before zero-width textprop removes itv8.1.2308
Problem: Deleting text before zero-width textprop removes it. Solution: Keep zero-width textprop when deleting text.
-rw-r--r--src/testdir/test_textprop.vim29
-rw-r--r--src/textprop.c5
-rw-r--r--src/version.c2
3 files changed, 35 insertions, 1 deletions
diff --git a/src/testdir/test_textprop.vim b/src/testdir/test_textprop.vim
index 467d833497..ded56a8600 100644
--- a/src/testdir/test_textprop.vim
+++ b/src/testdir/test_textprop.vim
@@ -650,6 +650,35 @@ func Test_prop_undo()
call prop_type_delete('comment')
endfunc
+func Test_prop_delete_text()
+ new
+ call prop_type_add('comment', {'highlight': 'Directory'})
+ call setline(1, ['oneone', 'twotwo', 'three'])
+
+ " zero length property
+ call prop_add(1, 3, {'type': 'comment'})
+ let expected = [{'col': 3, 'length': 0, 'id': 0, 'type': 'comment', 'start': 1, 'end': 1} ]
+ call assert_equal(expected, prop_list(1))
+
+ " delete one char moves the property
+ normal! x
+ let expected = [{'col': 2, 'length': 0, 'id': 0, 'type': 'comment', 'start': 1, 'end': 1} ]
+ call assert_equal(expected, prop_list(1))
+
+ " delete char of the property has no effect
+ normal! lx
+ let expected = [{'col': 2, 'length': 0, 'id': 0, 'type': 'comment', 'start': 1, 'end': 1} ]
+ call assert_equal(expected, prop_list(1))
+
+ " delete more chars moves property to first column, is not deleted
+ normal! 0xxxx
+ let expected = [{'col': 1, 'length': 0, 'id': 0, 'type': 'comment', 'start': 1, 'end': 1} ]
+ call assert_equal(expected, prop_list(1))
+
+ bwipe!
+ call prop_type_delete('comment')
+endfunc
+
" screenshot test with textprop highlighting
func Test_textprop_screenshot_various()
CheckScreendump
diff --git a/src/textprop.c b/src/textprop.c
index 71d671d6b8..55844d3ba2 100644
--- a/src/textprop.c
+++ b/src/textprop.c
@@ -1075,10 +1075,13 @@ adjust_prop_columns(
}
else if (bytes_added <= 0 && (tmp_prop.tp_col > col + 1))
{
+ int len_changed = FALSE;
+
if (tmp_prop.tp_col + bytes_added < col + 1)
{
tmp_prop.tp_len += (tmp_prop.tp_col - 1 - col) + bytes_added;
tmp_prop.tp_col = col + 1;
+ len_changed = TRUE;
}
else
tmp_prop.tp_col += bytes_added;
@@ -1086,7 +1089,7 @@ adjust_prop_columns(
if ((flags & APC_SAVE_FOR_UNDO) && !dirty)
u_savesub(lnum);
dirty = TRUE;
- if (tmp_prop.tp_len <= 0)
+ if (len_changed && tmp_prop.tp_len <= 0)
continue; // drop this text property
}
else if (tmp_prop.tp_len > 0
diff --git a/src/version.c b/src/version.c
index a682517de2..00aa9e8e3a 100644
--- a/src/version.c
+++ b/src/version.c
@@ -742,6 +742,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 2308,
+/**/
2307,
/**/
2306,