mirror of
https://github.com/neovim/neovim.git
synced 2025-10-16 14:56:08 +00:00
fix(column): crash with 'signcolumn' set to "number" (#29003)
Problem: Numberwidth may depend on number of signs with text in the buffer and is not handled correctly for extmark signs. Solution: Move legacy sign code for changed numberwidth so that it is handled properly for legacy and extmark signs alike.
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
#include "nvim/drawscreen.h"
|
||||
#include "nvim/extmark.h"
|
||||
#include "nvim/fold.h"
|
||||
#include "nvim/globals.h"
|
||||
#include "nvim/grid.h"
|
||||
#include "nvim/grid_defs.h"
|
||||
#include "nvim/highlight.h"
|
||||
@@ -184,6 +185,21 @@ void buf_put_decor(buf_T *buf, DecorInline decor, int row, int row2)
|
||||
}
|
||||
}
|
||||
|
||||
/// When displaying signs in the 'number' column, if the width of the number
|
||||
/// column is less than 2, then force recomputing the width after placing or
|
||||
/// unplacing the first sign in "buf".
|
||||
static void may_force_numberwidth_recompute(buf_T *buf, bool unplace)
|
||||
{
|
||||
FOR_ALL_TAB_WINDOWS(tp, wp) {
|
||||
if (wp->w_buffer == buf
|
||||
&& wp->w_minscwidth == SCL_NUM
|
||||
&& (wp->w_p_nu || wp->w_p_rnu)
|
||||
&& (unplace || wp->w_nrwidth_width < 2)) {
|
||||
wp->w_nrwidth_line_count = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int sign_add_id = 0;
|
||||
void buf_put_decor_sh(buf_T *buf, DecorSignHighlight *sh, int row1, int row2)
|
||||
{
|
||||
@@ -191,6 +207,7 @@ void buf_put_decor_sh(buf_T *buf, DecorSignHighlight *sh, int row1, int row2)
|
||||
sh->sign_add_id = sign_add_id++;
|
||||
if (sh->text[0]) {
|
||||
buf_signcols_count_range(buf, row1, row2, 1, kFalse);
|
||||
may_force_numberwidth_recompute(buf, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -218,6 +235,7 @@ void buf_remove_decor_sh(buf_T *buf, int row1, int row2, DecorSignHighlight *sh)
|
||||
if (buf_meta_total(buf, kMTMetaSignText)) {
|
||||
buf_signcols_count_range(buf, row1, row2, -1, kFalse);
|
||||
} else {
|
||||
may_force_numberwidth_recompute(buf, true);
|
||||
buf->b_signcols.resized = true;
|
||||
buf->b_signcols.max = buf->b_signcols.count[0] = 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user