Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix(decorations): line('w$') wrong in on_start#36957

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
tomtomjhj wants to merge1 commit intoneovim:master
base:master
Choose a base branch
Loading
fromtomtomjhj:on-start-botline

Conversation

@tomtomjhj
Copy link
Contributor

@tomtomjhjtomtomjhj commentedDec 14, 2025
edited
Loading

Problem:
When a floating window is created and drawn for the first time, line('w$') can be wrong in decoration provider on_start callback.

Solution:
Validate botline before invoking on_start.

Fixes:#36641,#36609.

Related:#26833

ribru17 and skewb1k reacted with rocket emoji
Problem:When a floating window is created and drawn for the first time,line('w$') can be wrong in decoration provider on_start callback.Solution:Validate botline before invoking on_start.
@tomtomjhjtomtomjhj marked this pull request as draftDecember 14, 2025 14:32
@github-actionsgithub-actionsbot removed the request for review frombfredlDecember 14, 2025 14:32
@tomtomjhj
Copy link
ContributorAuthor

tomtomjhj commentedDec 14, 2025
edited
Loading

I think this is not the correct fix.line('w$', win) itself doesvalidate_botline, soon_start shouldn't need to do it.

So the actual problem is why botline is incorrect after validation. I don't have time to investigate this right now. Here is my observation so far.

Apply this patch to print some logs

diff --git a/src/nvim/eval.c b/src/nvim/eval.cindex dd4ebf7be1..0070357fe1 100644--- a/src/nvim/eval.c+++ b/src/nvim/eval.c@@ -5363,12 +5363,14 @@ pos_T *var2fpos(const typval_T *const tv, const bool dollar_lnum, int *const ret      pos.col = 0;     if (name[1] == '0') {               // "w0": first visible line+      smsg(0, "var2pos('w0', %d)", curwin->handle);       update_topline(curwin);       // In silent Ex mode topline is zero, but that's not a valid line       // number; use one instead.       pos.lnum = curwin->w_topline > 0 ? curwin->w_topline : 1;       return &pos;     } else if (name[1] == '$') {      // "w$": last visible line+      smsg(0, "var2pos('w$', %d)", curwin->handle);       validate_botline(curwin);       // In silent Ex mode botline is zero, return zero then.       pos.lnum = curwin->w_botline > 0 ? curwin->w_botline - 1 : 0;diff --git a/src/nvim/move.c b/src/nvim/move.cindex 762f6b7d51..7cbbdaa0aa 100644--- a/src/nvim/move.c+++ b/src/nvim/move.c@@ -610,9 +610,11 @@ void changed_line_abv_curs_win(win_T *wp) // Make sure the value of wp->w_botline is valid. void validate_botline(win_T *wp) {+  smsg(0, "validate_botline %d, valid %d, botline %d", wp->handle, wp->w_valid, wp->w_botline);   if (!(wp->w_valid & VALID_BOTLINE)) {     comp_botline(wp);   }+  smsg(0, "updated botline %d", wp->w_botline); }  // Mark wp->w_botline as invalid (because of some change in the buffer).

Build, then run nvim withnvim --clean.
Run command:

lua vim.lsp.util.open_floating_preview({ '```lua', 'local foo', '```' }, 'markdown', { border = 'single', focus = false, })

Dismiss the hit-enter prompt and see the log with:mess:

validate_botline 1002, valid 0, botline 2updated botline 4var2pos('w0', 1002)validate_botline 1002, valid 0, botline 4updated botline 2var2pos('w$', 1002)validate_botline 1002, valid 248, botline 2updated botline 2validate_botline 1000, valid 255, botline 2updated botline 2validate_botline 1002, valid 248, botline 2updated botline 2

1002 is the win id of the floating window.
The first invocation ofvalidate_botline updates botline to the correct value, 4.
The next two invocations are fromline('w0', win) andline('w$', win) in tresitter highlighter'son_start callback.
Note that the second invocation somehow rolls back the botline to 2, which is unchanged by the third invocation (since it's marked valid).

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

LSP: incorrect highlights in floating wins of height 1

1 participant

@tomtomjhj

[8]ページ先頭

©2009-2025 Movatter.jp