Skip to content

refactor: always setlocal on window options#2263

Merged
ibhagwan merged 2 commits intoibhagwan:mainfrom
phanen:win-setlocal
Aug 20, 2025
Merged

refactor: always setlocal on window options#2263
ibhagwan merged 2 commits intoibhagwan:mainfrom
phanen:win-setlocal

Conversation

@phanen
Copy link
Copy Markdown
Collaborator

@phanen phanen commented Aug 19, 2025

  • refactor: always setlocal on window options
    • chore: remove useless autocmd
    • refactor: move logic to win:resized, win:save_size
    • refactor: simplify utils.eventignore
  • fix(previewer): prefer winopts.winhl (useful with non-float window as previewer)

phanen added 2 commits August 19, 2025 22:39
chore: remove useless autocmd

refactor: move logic to win:resized, win:save_size

refactor: simplify utils.eventignore
Comment thread lua/fzf-lua/actions.lua
if will_replace_curbuf
and vim.fn.exists("&winfixbuf") == 1
and vim.wo.winfixbuf
if will_replace_curbuf and utils.wo.winfixbuf
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Since this was added in 0.10 and we still support 0.9 don’t we still need vim.fn.exists("&winfixbuf") == 1?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

i change the semantic of utils.wo
see in tests/utils_spec

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

i write something wrong right vim.wo in eq should be utils.wo

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

i write something wrong right vim.wo in eq should be utils.wo

But it is utils.wo

if fn.exists("+eventignorewin") == 1 and vim.wo[win][0].eventignorewin == "" then
vim.wo[win][0].eventignorewin = "WinResized"
end
utils.wo[win].eventignorewin = "WinResized"
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Same as other comment, wasn’t eventignorewin only added with 0.10?

@ibhagwan ibhagwan merged commit 5a5f0e1 into ibhagwan:main Aug 20, 2025
7 checks passed
@staticssleever668
Copy link
Copy Markdown

After commit 05a4af9, preview windows have different background until the window is resized.
This is reproducible with https://raw.githubusercontent.com/ibhagwan/fzf-lua/main/scripts/mini.sh.
I'm on NVIM v0.11.3.

@ibhagwan
Copy link
Copy Markdown
Owner

#2266

ibhagwan added a commit that referenced this pull request Aug 20, 2025
@phanen
Copy link
Copy Markdown
Collaborator Author

phanen commented Aug 20, 2025

Resume this line seems work? idk why

diff --git a/lua/fzf-lua/win.lua b/lua/fzf-lua/win.lua
index c6957ce..5462533 100644
--- a/lua/fzf-lua/win.lua
+++ b/lua/fzf-lua/win.lua
@@ -531,7 +531,8 @@ function FzfWin:reset_win_highlights(win)
       end
     end
   end
-  utils.wo[win].winhl = hl
+  -- utils.wo[win].winhl = hl
+  if vim.wo[win].winhighlight ~= hl then vim.wo[win].winhighlight = hl end
 end
 
 ---@param exit_code integer

@ibhagwan
Copy link
Copy Markdown
Owner

5d2ba91

@phanen, not sure why nvim_set_option_value exhibits this behavior, try it with:

:hi! link FzfLuaPreviewNormal IncSearch
:FzfLua files

@ibhagwan
Copy link
Copy Markdown
Owner

Resume this line seems work? idk why

I'm confused too, but isn't vim.wo[winid] equals to nvim_set_option_value with scope=local?

@phanen
Copy link
Copy Markdown
Collaborator Author

phanen commented Aug 21, 2025

isn't vim.wo[winid] equals to nvim_set_option_value with scope=local?

no it‘s scope=nil

@ibhagwan
Copy link
Copy Markdown
Owner

isn't vim.wo[winid] equals to nvim_set_option_value with scope=local?

no it‘s scope=nil

I see, we can leave it like this until we figure out what’s wrong, as long as there’s no downside

@phanen
Copy link
Copy Markdown
Collaborator Author

phanen commented Aug 21, 2025

til
i misunderstand what setlocal does
neovim/neovim#24397 (comment)

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants