Skip to content

Commit

Permalink
fix: cancel pending requests as early as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
rchl committed Nov 2, 2024
1 parent 04827c7 commit d6c2988
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions plugin/session_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,18 @@ def on_text_changed_async(self, view: sublime.View, change_count: int,
self._pending_changes.update(change_count, changes)
purge = True
if purge:
self._cancel_pending_requests_async()
debounced(lambda: self.purge_changes_async(view), FEATURES_TIMEOUT,
lambda: view.is_valid() and change_count == view.change_count(), async_thread=True)

def _cancel_pending_requests_async(self) -> None:
if self._document_diagnostic_pending_request:
self.session.cancel_request(self._document_diagnostic_pending_request.request_id)
self._document_diagnostic_pending_request = None
if self.semantic_tokens.pending_response:
self.session.cancel_request(self.semantic_tokens.pending_response)
self.semantic_tokens.pending_response = None

def on_revert_async(self, view: sublime.View) -> None:
self._pending_changes = None # Don't bother with pending changes
version = view.change_count()
Expand Down

0 comments on commit d6c2988

Please sign in to comment.