vim-patch:8.1.0767: when deleting lines at the bottom signs are misplaced

Problem:    When deleting lines at the bottom signs are misplaced.
Solution:   Properly update the line number of signs at the end of a buffer
            after a delete/undo operation. (Yegappan Lakshmanan, closes vim/vim#3798)
c771bf9016
This commit is contained in:
Andrej Zieger
2019-05-20 20:04:47 +02:00
parent c5f3dbab35
commit fb4cf05e44
2 changed files with 50 additions and 4 deletions

View File

@@ -647,23 +647,31 @@ void sign_mark_adjust(linenr_T line1, linenr_T line2, long amount, long amount_a
signlist_T *sign; // a sign in a b_signlist
signlist_T *next; // the next sign in a b_signlist
signlist_T **lastp; // pointer to pointer to current sign
linenr_T new_lnum; // new line number to assign to sign
curbuf->b_signcols_max = -1;
lastp = &curbuf->b_signlist;
FOR_ALL_SIGNS_IN_BUF(curbuf, sign) {
next = sign->next;
new_lnum = sign->lnum;
if (sign->lnum >= line1 && sign->lnum <= line2) {
if (amount == MAXLNUM) {
*lastp = next;
xfree(sign);
continue;
} else {
sign->lnum += amount;
new_lnum += amount;
}
} else if (sign->lnum > line2) {
sign->lnum += amount_after;
new_lnum += amount_after;
}
// If the new sign line number is past the last line in the buffer,
// then don't adjust the line number. Otherwise, it will always be past
// the last line and will not be visible.
if (sign->lnum >= line1 && new_lnum <= curbuf->b_ml.ml_line_count) {
sign->lnum = new_lnum;
}
lastp = &sign->next;
}
}