Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into fix/global-listener
Browse files Browse the repository at this point in the history
* origin/main:
  Remove unnecessary parallel debouncing on selection change (#2529)
  Print URI error to status bar instead of error dialog (#2528)
  • Loading branch information
rchl committed Oct 14, 2024
2 parents b43942f + a6b17a4 commit 7d20cbe
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
20 changes: 11 additions & 9 deletions plugin/documents.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,8 @@ def __repr__(self) -> str:
class DocumentSyncListener(sublime_plugin.ViewEventListener, AbstractViewListener):

ACTIVE_DIAGNOSTIC = "lsp_active_diagnostic"
code_actions_debounce_time = FEATURES_TIMEOUT
debounce_time = FEATURES_TIMEOUT
color_boxes_debounce_time = FEATURES_TIMEOUT
highlights_debounce_time = FEATURES_TIMEOUT
code_lenses_debounce_time = FEATURES_TIMEOUT

@classmethod
Expand Down Expand Up @@ -388,16 +387,19 @@ def on_selection_modified_async(self) -> None:
return
if not self._is_in_higlighted_region(first_region.b):
self._clear_highlight_regions()
if userprefs().document_highlight_style:
self._when_selection_remains_stable_async(self._do_highlights_async, first_region,
after_ms=self.highlights_debounce_time)
self._clear_code_actions_annotation()
if userprefs().show_code_actions:
self._when_selection_remains_stable_async(self._do_code_actions_async, first_region,
after_ms=self.code_actions_debounce_time)
if userprefs().document_highlight_style or userprefs().show_code_actions:
self._when_selection_remains_stable_async(
self._on_selection_modified_debounced_async, first_region, after_ms=self.debounce_time)
self._update_diagnostic_in_status_bar_async()
self._resolve_visible_code_lenses_async()

def _on_selection_modified_debounced_async(self) -> None:
if userprefs().document_highlight_style:
self._do_highlights_async()
if userprefs().show_code_actions:
self._do_code_actions_async()

def on_post_save_async(self) -> None:
# Re-determine the URI; this time it's guaranteed to be a file because ST can only save files to a real
# filesystem.
Expand Down Expand Up @@ -952,7 +954,7 @@ def _on_view_updated_async(self) -> None:
self._clear_highlight_regions()
if userprefs().document_highlight_style:
self._when_selection_remains_stable_async(
self._do_highlights_async, first_region, after_ms=self.highlights_debounce_time)
self._do_highlights_async, first_region, after_ms=self.debounce_time)
self.do_signature_help_async(manual=False)

def _update_stored_selection_async(self) -> tuple[sublime.Region | None, bool]:
Expand Down
5 changes: 4 additions & 1 deletion plugin/locationpicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ def open_location_async(

def check_success_async(view: sublime.View | None) -> None:
if not view:
sublime.error_message("Unable to open URI")
uri = get_uri_and_position_from_location(location)[0]
msg = f"Unable to open URI {uri}"
debug(msg)
session.window.status_message(msg)

session.open_location_async(location, flags, group).then(check_success_async)

Expand Down
6 changes: 3 additions & 3 deletions tests/test_code_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,11 @@ def test_kind_matching(self) -> None:
class CodeActionsListenerTestCase(TextDocumentTestCase):
def setUp(self) -> Generator:
yield from super().setUp()
self.original_debounce_time = DocumentSyncListener.code_actions_debounce_time
DocumentSyncListener.code_actions_debounce_time = 0
self.original_debounce_time = DocumentSyncListener.debounce_time
DocumentSyncListener.debounce_time = 0

def tearDown(self) -> None:
DocumentSyncListener.code_actions_debounce_time = self.original_debounce_time
DocumentSyncListener.debounce_time = self.original_debounce_time
super().tearDown()

@classmethod
Expand Down

0 comments on commit 7d20cbe

Please sign in to comment.