• R/O
  • SSH

vim: Commit

Mirror of the Vim source from https://github.com/vim/vim


Commit MetaInfo

Révision78ebb50d6fcb332d2fd2dbdfd0b0ee7476832805 (tree)
l'heure2022-05-16 06:30:03
AuteurBram Moolenaar <Bram@vim....>
CommiterBram Moolenaar

Message de Log

patch 8.2.4960: text properties that cross lines not updated for deleted line

Commit: https://github.com/vim/vim/commit/1bdc60eb91b9e6320318d96ea59bd2aad775f408
Author: Paul Ollis <paul@cleversheep.org>
Date: Sun May 15 22:24:55 2022 +0100

patch 8.2.4960: text properties that cross lines not updated for deleted line
Problem: Text properties that cross line boundary are not correctly updated
for a deleted line.
Solution: Correct computing location of text property entry. (Paul Ollis,
closes #10431, closes #10430)

Change Summary

Modification

diff -r 6ba9359f8c36 -r 78ebb50d6fcb src/memline.c
--- a/src/memline.c Sun May 15 16:00:04 2022 +0200
+++ b/src/memline.c Sun May 15 23:30:03 2022 +0200
@@ -3501,8 +3501,9 @@
35013501 #ifdef FEAT_PROP_POPUP
35023502 /*
35033503 * Adjust text properties in line "lnum" for a deleted line.
3504- * When "above" is true this is the line above the deleted line.
3505- * "del_props" are the properties of the deleted line.
3504+ * When "above" is true this is the line above the deleted line, otherwise this
3505+ * is the line below the deleted line.
3506+ * "del_props[del_props_len]" are the properties of the deleted line.
35063507 */
35073508 static void
35083509 adjust_text_props_for_delete(
@@ -3569,7 +3570,7 @@
35693570 : TP_FLAG_CONT_PREV;
35703571 textprop_T prop_this;
35713572
3572- mch_memmove(&prop_this, text + textlen + done_del,
3573+ mch_memmove(&prop_this, text + textlen + done_this,
35733574 sizeof(textprop_T));
35743575 if ((prop_this.tp_flags & flag)
35753576 && prop_del.tp_id == prop_this.tp_id
@@ -3577,7 +3578,7 @@
35773578 {
35783579 found = TRUE;
35793580 prop_this.tp_flags &= ~flag;
3580- mch_memmove(text + textlen + done_del, &prop_this,
3581+ mch_memmove(text + textlen + done_this, &prop_this,
35813582 sizeof(textprop_T));
35823583 break;
35833584 }
diff -r 6ba9359f8c36 -r 78ebb50d6fcb src/testdir/test_textprop.vim
--- a/src/testdir/test_textprop.vim Sun May 15 16:00:04 2022 +0200
+++ b/src/testdir/test_textprop.vim Sun May 15 23:30:03 2022 +0200
@@ -1645,6 +1645,57 @@
16451645 bwipe!
16461646 enddef
16471647
1648+" This test is to detect a regression related to #10430. It is not an attempt
1649+" fully cover deleting lines in the presence of multi-line properties.
1650+def Test_delete_line_within_multiline_prop()
1651+ new
1652+ setline(1, '# Top.')
1653+ append(1, ['some_text = """', 'A string.', '"""', '# Bottom.'])
1654+ prop_type_add('Identifier', {'highlight': 'ModeMsg', 'priority': 0, 'combine': 0, 'start_incl': 0, 'end_incl': 0})
1655+ prop_type_add('String', {'highlight': 'MoreMsg', 'priority': 0, 'combine': 0, 'start_incl': 0, 'end_incl': 0})
1656+ prop_add(2, 1, {'type': 'Identifier', 'end_lnum': 2, 'end_col': 9})
1657+ prop_add(2, 13, {'type': 'String', 'end_lnum': 4, 'end_col': 4})
1658+
1659+ # The property for line 3 should extend into the previous and next lines.
1660+ var props = prop_list(3)
1661+ var prop = props[0]
1662+ assert_equal(1, len(props))
1663+ assert_equal(0, prop['start'])
1664+ assert_equal(0, prop['end'])
1665+
1666+ # This deletion should run without raising an exception.
1667+ try
1668+ :2 del
1669+ catch
1670+ assert_report('Line delete should have workd, but it raised an error.')
1671+ endtry
1672+
1673+ # The property for line 2 (was 3) should no longer extend into the previous
1674+ # line.
1675+ props = prop_list(2)
1676+ prop = props[0]
1677+ assert_equal(1, len(props))
1678+ assert_equal(1, prop['start'], 'Property was not changed to start within the line.')
1679+
1680+ # This deletion should run without raising an exception.
1681+ try
1682+ :3 del
1683+ catch
1684+ assert_report('Line delete should have workd, but it raised an error.')
1685+ endtry
1686+
1687+ # The property for line 2 (originally 3) should no longer extend into the next
1688+ # line.
1689+ props = prop_list(2)
1690+ prop = props[0]
1691+ assert_equal(1, len(props))
1692+ assert_equal(1, prop['end'], 'Property was not changed to end within the line.')
1693+
1694+ prop_type_delete('Identifier')
1695+ prop_type_delete('String')
1696+ bwip!
1697+enddef
1698+
16481699 func Test_prop_in_linebreak()
16491700 CheckRunVimInTerminal
16501701
diff -r 6ba9359f8c36 -r 78ebb50d6fcb src/version.c
--- a/src/version.c Sun May 15 16:00:04 2022 +0200
+++ b/src/version.c Sun May 15 23:30:03 2022 +0200
@@ -747,6 +747,8 @@
747747 static int included_patches[] =
748748 { /* Add new patch number below this line */
749749 /**/
750+ 4960,
751+/**/
750752 4959,
751753 /**/
752754 4958,
Afficher sur ancien navigateur de dépôt.