Mercurial > vim
diff src/sign.c @ 15519:89e76a598b30 v8.1.0767
patch 8.1.0767: when deleting lines at the bottom signs are misplaced
commit https://github.com/vim/vim/commit/c771bf901622064dc27421b04853e16b6914a295
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jan 17 17:36:45 2019 +0100
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 #3798)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 17 Jan 2019 17:45:06 +0100 |
parents | 98c35d312987 |
children | 233e2c585e03 |
line wrap: on
line diff
--- a/src/sign.c +++ b/src/sign.c @@ -660,18 +660,28 @@ sign_mark_adjust( long amount_after) { signlist_T *sign; // a sign in a b_signlist + linenr_T new_lnum; FOR_ALL_SIGNS_IN_BUF(curbuf, sign) { + // Ignore changes to lines after the sign + if (sign->lnum < line1) + continue; + new_lnum = sign->lnum; if (sign->lnum >= line1 && sign->lnum <= line2) { - if (amount == MAXLNUM) - sign->lnum = line1; - else - sign->lnum += amount; + if (amount != MAXLNUM) + new_lnum += amount; } else if (sign->lnum > line2) - sign->lnum += amount_after; + // Lines inserted or deleted before the sign + 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 (new_lnum <= curbuf->b_ml.ml_line_count) + sign->lnum = new_lnum; } }