diff options
author | Matthieu Coudron <teto@users.noreply.github.com> | 2021-04-18 17:12:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-04-18 17:12:41 +0200 |
commit | e343437bb6b82a48b1001d98a08fb5c63dccda30 (patch) | |
tree | e9f487113ba6e3402e837fc7872a250183980077 /src/nvim/sign.c | |
parent | a129887c00a2d5e49fc551ba0bbffe88cefb56c0 (diff) | |
parent | 5b8575fa0dc689e6de90ee3cc6805c0f8742c320 (diff) | |
download | rneovim-e343437bb6b82a48b1001d98a08fb5c63dccda30.tar.gz rneovim-e343437bb6b82a48b1001d98a08fb5c63dccda30.tar.bz2 rneovim-e343437bb6b82a48b1001d98a08fb5c63dccda30.zip |
Merge pull request #12323 from da-x/orphaned-signs
Handle 'orphaned signs' on line deletion for signcolumn >= 2
Diffstat (limited to 'src/nvim/sign.c')
-rw-r--r-- | src/nvim/sign.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/nvim/sign.c b/src/nvim/sign.c index c7dc1a5b22..5c7b497a19 100644 --- a/src/nvim/sign.c +++ b/src/nvim/sign.c @@ -18,6 +18,7 @@ #include "nvim/move.h" #include "nvim/screen.h" #include "nvim/syntax.h" +#include "nvim/option.h" /// Struct to hold the sign properties. typedef struct sign sign_T; @@ -726,15 +727,29 @@ void sign_mark_adjust( long amount_after ) { - sign_entry_T *sign; // a sign in a b_signlist - linenr_T new_lnum; // new line number to assign to sign + sign_entry_T *sign; // a sign in a b_signlist + sign_entry_T *next; // the next sign in a b_signlist + sign_entry_T *last = NULL; // pointer to pointer to current sign + sign_entry_T **lastp = NULL; // pointer to pointer to current sign + linenr_T new_lnum; // new line number to assign to sign + int is_fixed = 0; + int signcol = win_signcol_configured(curwin, &is_fixed); curbuf->b_signcols_max = -1; + lastp = &curbuf->b_signlist; - FOR_ALL_SIGNS_IN_BUF(curbuf, sign) { + for (sign = curbuf->b_signlist; sign != NULL; sign = next) { + next = sign->se_next; new_lnum = sign->se_lnum; if (sign->se_lnum >= line1 && sign->se_lnum <= line2) { - if (amount != MAXLNUM) { + if (amount == MAXLNUM && (!is_fixed || signcol >= 2)) { + *lastp = next; + if (next) { + next->se_prev = last; + } + xfree(sign); + continue; + } else { new_lnum += amount; } } else if (sign->se_lnum > line2) { @@ -746,6 +761,9 @@ void sign_mark_adjust( if (sign->se_lnum >= line1 && new_lnum <= curbuf->b_ml.ml_line_count) { sign->se_lnum = new_lnum; } + + last = sign; + lastp = &sign->se_next; } } |