mirror of
https://github.com/neovim/neovim.git
synced 2025-10-05 09:26:30 +00:00
fix(column): keep track of number of lines with number of signs
Problem: Some edge cases to the old (pre-#26406) and current "b_signcols" structure result in an incorrectly sized "auto" 'signcolumn'. Solution: * Implement a simpler 'signcolumn' validation strategy by immediately counting the number of signs in a range upon sign insertion and deletion. Decrease in performance here but there is a clear path forward to decreasing this performance hit by moving signs to a dedicated marktree, or by adding meta-data to the existing marktree which may be queried more efficiently? * Also replace "max_count" and keep track of the number of lines with a certain number of signs. This makes it so that it is no longer necessary to scan the entire buffer when the maximum number of signs decreases. This likely makes the commit a net increase in performance. * To ensure correctness we also have re-initialize the count for an edited region that spans multiple lines. Such an edit may move the signs within it. Thus we count and decrement before splicing the marktree and count and increment after.
This commit is contained in:

committed by
Lewis Russell

parent
4d91604c88
commit
967c7abde3
@@ -521,10 +521,19 @@ void extmark_splice_impl(buf_T *buf, int start_row, colnr_T start_col, bcount_t
|
||||
extmark_splice_delete(buf, start_row, start_col, end_row, end_col, uvp, false, undo);
|
||||
}
|
||||
|
||||
// Remove signs inside edited region from "b_signcols.count", add after splicing.
|
||||
if (old_row > 0 || new_row > 0) {
|
||||
buf_signcols_count_range(buf, start_row, start_row + old_row + 1, 0, kTrue);
|
||||
}
|
||||
|
||||
marktree_splice(buf->b_marktree, (int32_t)start_row, start_col,
|
||||
old_row, old_col,
|
||||
new_row, new_col);
|
||||
|
||||
if (old_row > 0 || new_row > 0) {
|
||||
buf_signcols_count_range(buf, start_row, start_row + new_row + 1, 0, kNone);
|
||||
}
|
||||
|
||||
if (undo == kExtmarkUndo) {
|
||||
u_header_T *uhp = u_force_get_undo_header(buf);
|
||||
if (!uhp) {
|
||||
@@ -603,10 +612,16 @@ void extmark_move_region(buf_T *buf, int start_row, colnr_T start_col, bcount_t
|
||||
extent_row, extent_col, extent_byte,
|
||||
0, 0, 0);
|
||||
|
||||
int row1 = MIN(start_row, new_row);
|
||||
int row2 = MAX(start_row, new_row) + extent_row;
|
||||
buf_signcols_count_range(buf, row1, row2, 0, kTrue);
|
||||
|
||||
marktree_move_region(buf->b_marktree, start_row, start_col,
|
||||
extent_row, extent_col,
|
||||
new_row, new_col);
|
||||
|
||||
buf_signcols_count_range(buf, row1, row2, 0, kNone);
|
||||
|
||||
buf_updates_send_splice(buf, new_row, new_col, new_byte,
|
||||
0, 0, 0,
|
||||
extent_row, extent_col, extent_byte);
|
||||
|
Reference in New Issue
Block a user