Skip to content

Conversation

vanaigr
Copy link
Contributor

@vanaigr vanaigr commented Sep 1, 2025

fixes #35575

Problem:
When decoration provider is invoked and there's no more decorations, it sets col_until to MAXCOL. However, with the addition of range based highlighting, more decorations may be added afterwards, but they would be ignored.

Solution:
Use last column of the range of the requested decorations as maximum for col_until

I also renamed col_until to col_last since it is not end-exclusive.

@github-actions github-actions bot added the spell spellcheck label Sep 1, 2025
@vanaigr
Copy link
Contributor Author

vanaigr commented Sep 1, 2025

For #35575, the issue happened because I rebased incorrectly and used the wrong variable (see: #35575 (comment)), so when window height matched a position on the line with no decorations, the issue occured.

Reproduction:

-- window height is 5, 9, 11, 13, 15, ...
vim.cmd('set nowrap')
vim.api.nvim_buf_set_lines(0, 0, -1, true, {
  'local foo = { { severity = 0 }, { severity = 1 }, { severity = 2 }, { severity = 3 }, { severity = 0 }, { severity = 1 }, { severity = 2 }, { severity = 3 }, { severity = 0 }, { severity = 1 }, { severity = 2 }, { serity = 3 } }'
})
vim.cmd('set ft=lua')

UPD: also fixed this

@vanaigr vanaigr force-pushed the decor-fix-col_until branch from 7e952e9 to 225b480 Compare September 1, 2025 16:11
@@ -1268,7 +1268,7 @@ static TriState decor_spell_nav_col(win_T *wp, linenr_T lnum, linenr_T *decor_ln
decor_redraw_line(wp, lnum - 1, &decor_state);
*decor_lnum = lnum;
}
decor_redraw_col(wp, col, 0, false, &decor_state);
decor_redraw_col(wp, col, 0, false, &decor_state, MAXCOL);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used MAXCOL here since I think decor_state is reset afterwards, so the column doesn't affect anything

@@ -792,7 +793,7 @@ int decor_redraw_col_impl(win_T *wp, int col, int win_col, bool hidden, DecorSta
DecorSignHighlight *sh = &r->data.sh;
conceal = 2;
conceal_char = sh->text[0];
col_until = MIN(col_until, r->start_col);
col_last = MIN(col_last, r->start_col);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this code assumes the character is 1 byte, and this is start_col + char_len - 1.

Are conceal characters always single byte?

@vanaigr vanaigr force-pushed the decor-fix-col_until branch from 225b480 to e9a357e Compare September 1, 2025 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
spell spellcheck
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TS Highlights Fail to Display with Nowrap + Gutter
1 participant