Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Focus symbol closest to selection on showing document symbols #2094

Merged
merged 1 commit into from
Oct 21, 2022

Conversation

rchl
Copy link
Member

@rchl rchl commented Oct 21, 2022

Match ST behavior and focus symbol closest to selection on triggering Go to Symbol command.

Taking end point of first selection and finding symbol that intersects it or is just before it.

I think ST might have slightly different behavior with multiple selections (takes into account last while we take first) but otherwise it should match ST behavior.

Fixes #2093

@@ -109,13 +108,22 @@ def handle_response(self, response: Union[List[DocumentSymbol], List[SymbolInfor
self.view.settings().erase(SUPPRESS_INPUT_SETTING_KEY)
window = self.view.window()
if window and isinstance(response, list) and len(response) > 0:
panel_items = self.process_symbols(response)
Copy link
Member Author

Choose a reason for hiding this comment

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

I hate code that creates side effects (self.regions) and also returns something but decided not to refactor anything here.

Comment on lines -149 to -151
if self.is_first_selection:
self.is_first_selection = False
return
Copy link
Member Author

@rchl rchl Oct 21, 2022

Choose a reason for hiding this comment

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

We had code that prevented scrolling to selected symbol on opening the quick panel but with this behavior change I think it's no longer needed. Otherwise the behavior would be inconsistent as the outline would not show initially but only after changing selection.

Copy link
Member

@predragnikolic predragnikolic left a comment

Choose a reason for hiding this comment

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

Tested, works.

@predragnikolic predragnikolic merged commit 4b5cf55 into main Oct 21, 2022
@predragnikolic predragnikolic deleted the fix/sybol-focus branch October 21, 2022 20:17
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.

lsp_document_symbols should initially focus on current symbol under caret
2 participants