Mirror of the Vim source from https://github.com/vim/vim
Révision | 78ebb50d6fcb332d2fd2dbdfd0b0ee7476832805 (tree) |
---|---|
l'heure | 2022-05-16 06:30:03 |
Auteur | Bram Moolenaar <Bram@vim....> |
Commiter | Bram Moolenaar |
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
@@ -3501,8 +3501,9 @@ | ||
3501 | 3501 | #ifdef FEAT_PROP_POPUP |
3502 | 3502 | /* |
3503 | 3503 | * 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. | |
3506 | 3507 | */ |
3507 | 3508 | static void |
3508 | 3509 | adjust_text_props_for_delete( |
@@ -3569,7 +3570,7 @@ | ||
3569 | 3570 | : TP_FLAG_CONT_PREV; |
3570 | 3571 | textprop_T prop_this; |
3571 | 3572 | |
3572 | - mch_memmove(&prop_this, text + textlen + done_del, | |
3573 | + mch_memmove(&prop_this, text + textlen + done_this, | |
3573 | 3574 | sizeof(textprop_T)); |
3574 | 3575 | if ((prop_this.tp_flags & flag) |
3575 | 3576 | && prop_del.tp_id == prop_this.tp_id |
@@ -3577,7 +3578,7 @@ | ||
3577 | 3578 | { |
3578 | 3579 | found = TRUE; |
3579 | 3580 | prop_this.tp_flags &= ~flag; |
3580 | - mch_memmove(text + textlen + done_del, &prop_this, | |
3581 | + mch_memmove(text + textlen + done_this, &prop_this, | |
3581 | 3582 | sizeof(textprop_T)); |
3582 | 3583 | break; |
3583 | 3584 | } |
@@ -1645,6 +1645,57 @@ | ||
1645 | 1645 | bwipe! |
1646 | 1646 | enddef |
1647 | 1647 | |
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 | + | |
1648 | 1699 | func Test_prop_in_linebreak() |
1649 | 1700 | CheckRunVimInTerminal |
1650 | 1701 |
@@ -747,6 +747,8 @@ | ||
747 | 747 | static int included_patches[] = |
748 | 748 | { /* Add new patch number below this line */ |
749 | 749 | /**/ |
750 | + 4960, | |
751 | +/**/ | |
750 | 752 | 4959, |
751 | 753 | /**/ |
752 | 754 | 4958, |