Skip to content

Commit

Permalink
Make input suppression for document symbols more reliable (#2347)
Browse files Browse the repository at this point in the history
  • Loading branch information
jwortmann authored Oct 26, 2023
1 parent 661ff53 commit 3b17a99
Showing 1 changed file with 6 additions and 2 deletions.
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

0 comments on commit 3b17a99

Please sign in to comment.