fix(lsp): remove signature auto focus - #1215
Open
Carrot-shreds wants to merge 1 commit into
Open
Conversation
4 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Change the default signature create action to solve the focus steal issue by replace
focus()withwin().focus(): check if the window exist, if true, set foucs into it.win(): only return the window id, (for window checking here).The old code uses
message:focus()for both window detection and focus management (same as the hover window). If there don't have a window, we open a new one. And if there is already a window, we focus into it.It makes sense for hover window, because it usually be toggled manually. But the signature mostly be triggerd automaticlly by the lsp. Under fast editing or navigating, the
checkmight be called frequently and cause unexpected focus loss.About
focusablenot workingInside of
focususesnvim_set_current_win()to switch foucs. That's why it's useless just setting the windowfocus=false.The lsp signature now will no longer mass up your focus. But I keep the
K+Kfocus in for the hover window. If you use some kind of autocmd for hover, and don't want auto focus. You should check if the window already exists in your script likeif require("noice.lsp.docs").get("hover"):win().Stable Reproduction
func+(+(You prees
(, and signature window appears. After that, because the nvim.lsp.signaturesetup()attachedTextChangedIwithcheck(). So after you typing another(, there will trigger anothercheck(), recognize the bracket and try to open the signature window again, steals focus from the editor area.func((+ backspaceSame reason as the above case.
Related Issue(s)
Fixes #1172 #1016 #1101
Related #1206 #1017 #698
I also considerd to make the focus optional, but it needs extra config and code refactor. I finally choose to make the commit simple.
For those who still want to focus to the signature window manually, you can bind a key like: