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

Make input suppression for document symbols more reliable #2347

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions plugin/symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ def input(self, args: dict) -> Optional[sublime_plugin.CommandInputHandler]:
self.cached = False
if self.kind and not any(item.value['kind'] == self.kind for item in self.items):
self.has_matching_symbols = False
self._reset_suppress_input()
return None
window = self.view.window()
if not window:
Expand All @@ -183,11 +184,11 @@ def input(self, args: dict) -> Optional[sublime_plugin.CommandInputHandler]:
SYMBOL_KIND_NAMES.get(symbol_kind, 'All Kinds'),
self.kind,
kind=SYMBOL_KINDS.get(symbol_kind, sublime.KIND_AMBIGUOUS))
sublime.set_timeout(self._reset_suppress_input)
return DocumentSymbolsKindInputHandler(window, initial_value, self.view, self.items)
return None

def handle_response_async(self, response: Union[List[DocumentSymbol], List[SymbolInformation], None]) -> None:
self.view.settings().erase(SUPPRESS_INPUT_SETTING_KEY)
self.items.clear()
if response and self.view.is_valid():
if 'selectionRange' in response[0]:
Expand All @@ -205,9 +206,12 @@ def handle_response_async(self, response: Union[List[DocumentSymbol], List[Symbo
window.run_command('show_overlay', {'overlay': 'command_palette', 'command': 'lsp_document_symbols'})

def handle_response_error(self, error: Any) -> None:
self.view.settings().erase(SUPPRESS_INPUT_SETTING_KEY)
self._reset_suppress_input()
print_to_status_bar(error)

def _reset_suppress_input(self) -> None:
self.view.settings().erase(SUPPRESS_INPUT_SETTING_KEY)

def process_document_symbol_recursive(
self, item: DocumentSymbol, hierarchy: str = ''
) -> List[sublime.ListInputItem]:
Expand Down