diff options
-rw-r--r-- | src/nvim/buffer_defs.h | 1 | ||||
-rw-r--r-- | src/nvim/decoration.c | 14 | ||||
-rw-r--r-- | src/nvim/extmark.c | 1 | ||||
-rw-r--r-- | test/functional/ui/decorations_spec.lua | 14 |
4 files changed, 25 insertions, 5 deletions
diff --git a/src/nvim/buffer_defs.h b/src/nvim/buffer_defs.h index 4c99191170..3601dc7062 100644 --- a/src/nvim/buffer_defs.h +++ b/src/nvim/buffer_defs.h @@ -838,6 +838,7 @@ struct file_buffer { Map(uint32_t, uint32_t) b_extmark_ns[1]; // extmark namespaces size_t b_virt_line_blocks; // number of virt_line blocks size_t b_signs; // number of sign extmarks + size_t b_signs_with_text; // number of sign extmarks with text // array of channel_id:s which have asked to receive updates for this // buffer. diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c index 63c55ec602..c98ffbeefb 100644 --- a/src/nvim/decoration.c +++ b/src/nvim/decoration.c @@ -100,9 +100,13 @@ void decor_remove(buf_T *buf, int row, int row2, Decoration *decor) if (decor_has_sign(decor)) { assert(buf->b_signs > 0); buf->b_signs--; - } - if (row2 >= row && decor->sign_text) { - buf_signcols_del_check(buf, row + 1, row2 + 1); + if (decor->sign_text) { + assert(buf->b_signs_with_text > 0); + buf->b_signs_with_text--; + if (row2 >= row) { + buf_signcols_del_check(buf, row + 1, row2 + 1); + } + } } } decor_free(decor); @@ -445,11 +449,11 @@ int decor_signcols(buf_T *buf, DecorState *state, int row, int end_row, int max) int signcols = 0; // highest value of count int currow = -1; // current row - if (max <= 1 && buf->b_signs >= (size_t)max) { + if (max <= 1 && buf->b_signs_with_text >= (size_t)max) { return max; } - if (buf->b_signs == 0) { + if (buf->b_signs_with_text == 0) { return 0; } diff --git a/src/nvim/extmark.c b/src/nvim/extmark.c index 3e059bcc6c..1132a5e752 100644 --- a/src/nvim/extmark.c +++ b/src/nvim/extmark.c @@ -152,6 +152,7 @@ revised: buf->b_signs++; } if (decor->sign_text) { + buf->b_signs_with_text++; // TODO(lewis6991): smarter invalidation buf_signcols_add_check(buf, NULL); } diff --git a/test/functional/ui/decorations_spec.lua b/test/functional/ui/decorations_spec.lua index 489c33d8b1..6ed32a8cd4 100644 --- a/test/functional/ui/decorations_spec.lua +++ b/test/functional/ui/decorations_spec.lua @@ -2109,6 +2109,20 @@ l5 | ]]} end) + + it('does not set signcolumn for signs without text', function() + screen:try_resize(20, 3) + meths.win_set_option(0, 'signcolumn', 'auto') + insert(example_text) + feed 'gg' + meths.buf_set_extmark(0, ns, 0, -1, {number_hl_group='Error'}) + screen:expect{grid=[[ + ^l1 | + l2 | + | + ]]} + end) + end) describe('decorations: virt_text', function() |