Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
15518:a99eedb83c56 | 15519:89e76a598b30 |
---|---|
658 linenr_T line2, | 658 linenr_T line2, |
659 long amount, | 659 long amount, |
660 long amount_after) | 660 long amount_after) |
661 { | 661 { |
662 signlist_T *sign; // a sign in a b_signlist | 662 signlist_T *sign; // a sign in a b_signlist |
663 linenr_T new_lnum; | |
663 | 664 |
664 FOR_ALL_SIGNS_IN_BUF(curbuf, sign) | 665 FOR_ALL_SIGNS_IN_BUF(curbuf, sign) |
665 { | 666 { |
667 // Ignore changes to lines after the sign | |
668 if (sign->lnum < line1) | |
669 continue; | |
670 new_lnum = sign->lnum; | |
666 if (sign->lnum >= line1 && sign->lnum <= line2) | 671 if (sign->lnum >= line1 && sign->lnum <= line2) |
667 { | 672 { |
668 if (amount == MAXLNUM) | 673 if (amount != MAXLNUM) |
669 sign->lnum = line1; | 674 new_lnum += amount; |
670 else | |
671 sign->lnum += amount; | |
672 } | 675 } |
673 else if (sign->lnum > line2) | 676 else if (sign->lnum > line2) |
674 sign->lnum += amount_after; | 677 // Lines inserted or deleted before the sign |
678 new_lnum += amount_after; | |
679 | |
680 // If the new sign line number is past the last line in the buffer, | |
681 // then don't adjust the line number. Otherwise, it will always be past | |
682 // the last line and will not be visible. | |
683 if (new_lnum <= curbuf->b_ml.ml_line_count) | |
684 sign->lnum = new_lnum; | |
675 } | 685 } |
676 } | 686 } |
677 | 687 |
678 /* | 688 /* |
679 * Find index of a ":sign" subcmd from its name. | 689 * Find index of a ":sign" subcmd from its name. |