Skip to content

Commit 7d20cbe

Browse files
committed
Merge remote-tracking branch 'origin/main' into fix/global-listener
* origin/main: Remove unnecessary parallel debouncing on selection change (#2529) Print URI error to status bar instead of error dialog (#2528)
2 parents b43942f + a6b17a4 commit 7d20cbe

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

plugin/documents.py

+11-9
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,8 @@ def __repr__(self) -> str:
139139
class DocumentSyncListener(sublime_plugin.ViewEventListener, AbstractViewListener):
140140

141141
ACTIVE_DIAGNOSTIC = "lsp_active_diagnostic"
142-
code_actions_debounce_time = FEATURES_TIMEOUT
142+
debounce_time = FEATURES_TIMEOUT
143143
color_boxes_debounce_time = FEATURES_TIMEOUT
144-
highlights_debounce_time = FEATURES_TIMEOUT
145144
code_lenses_debounce_time = FEATURES_TIMEOUT
146145

147146
@classmethod
@@ -388,16 +387,19 @@ def on_selection_modified_async(self) -> None:
388387
return
389388
if not self._is_in_higlighted_region(first_region.b):
390389
self._clear_highlight_regions()
391-
if userprefs().document_highlight_style:
392-
self._when_selection_remains_stable_async(self._do_highlights_async, first_region,
393-
after_ms=self.highlights_debounce_time)
394390
self._clear_code_actions_annotation()
395-
if userprefs().show_code_actions:
396-
self._when_selection_remains_stable_async(self._do_code_actions_async, first_region,
397-
after_ms=self.code_actions_debounce_time)
391+
if userprefs().document_highlight_style or userprefs().show_code_actions:
392+
self._when_selection_remains_stable_async(
393+
self._on_selection_modified_debounced_async, first_region, after_ms=self.debounce_time)
398394
self._update_diagnostic_in_status_bar_async()
399395
self._resolve_visible_code_lenses_async()
400396

397+
def _on_selection_modified_debounced_async(self) -> None:
398+
if userprefs().document_highlight_style:
399+
self._do_highlights_async()
400+
if userprefs().show_code_actions:
401+
self._do_code_actions_async()
402+
401403
def on_post_save_async(self) -> None:
402404
# Re-determine the URI; this time it's guaranteed to be a file because ST can only save files to a real
403405
# filesystem.
@@ -952,7 +954,7 @@ def _on_view_updated_async(self) -> None:
952954
self._clear_highlight_regions()
953955
if userprefs().document_highlight_style:
954956
self._when_selection_remains_stable_async(
955-
self._do_highlights_async, first_region, after_ms=self.highlights_debounce_time)
957+
self._do_highlights_async, first_region, after_ms=self.debounce_time)
956958
self.do_signature_help_async(manual=False)
957959

958960
def _update_stored_selection_async(self) -> tuple[sublime.Region | None, bool]:

plugin/locationpicker.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ def open_location_async(
3030

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

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

tests/test_code_actions.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -269,11 +269,11 @@ def test_kind_matching(self) -> None:
269269
class CodeActionsListenerTestCase(TextDocumentTestCase):
270270
def setUp(self) -> Generator:
271271
yield from super().setUp()
272-
self.original_debounce_time = DocumentSyncListener.code_actions_debounce_time
273-
DocumentSyncListener.code_actions_debounce_time = 0
272+
self.original_debounce_time = DocumentSyncListener.debounce_time
273+
DocumentSyncListener.debounce_time = 0
274274

275275
def tearDown(self) -> None:
276-
DocumentSyncListener.code_actions_debounce_time = self.original_debounce_time
276+
DocumentSyncListener.debounce_time = self.original_debounce_time
277277
super().tearDown()
278278

279279
@classmethod

0 commit comments

Comments
 (0)