Skip to content

Commit

Permalink
handle corner case
Browse files Browse the repository at this point in the history
  • Loading branch information
rchl committed Nov 2, 2024
1 parent d6c2988 commit a74d521
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
12 changes: 7 additions & 5 deletions plugin/core/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ def update_document_link(self, new_link: DocumentLink) -> None:
def do_semantic_tokens_async(self, view: sublime.View) -> None:
...

def set_semantic_tokens_pending_refresh(self, needs_refresh: bool = True) -> None:
def set_semantic_tokens_pending_refresh(self, needs_refresh: bool = ...) -> None:
...

def get_semantic_tokens(self) -> list[Any]:
Expand All @@ -680,16 +680,18 @@ def get_semantic_tokens(self) -> list[Any]:
def do_inlay_hints_async(self, view: sublime.View) -> None:
...

def set_inlay_hints_pending_refresh(self, needs_refresh: bool = True) -> None:
def set_inlay_hints_pending_refresh(self, needs_refresh: bool = ...) -> None:
...

def remove_inlay_hint_phantom(self, phantom_uuid: str) -> None:
...

def do_document_diagnostic_async(self, view: sublime.View, version: int | None = None) -> None:
def do_document_diagnostic_async(
self, view: sublime.View, version: int | None = ..., *, ignore_pending: bool = ...
) -> None:
...

def set_document_diagnostic_pending_refresh(self, needs_refresh: bool = True) -> None:
def set_document_diagnostic_pending_refresh(self, needs_refresh: bool = ...) -> None:
...


Expand Down Expand Up @@ -2070,7 +2072,7 @@ def m_workspace_diagnostic_refresh(self, params: None, request_id: Any) -> None:
self.send_response(Response(request_id, None))
visible_session_views, not_visible_session_views = self.session_views_by_visibility()
for sv in visible_session_views:
sv.session_buffer.do_document_diagnostic_async(sv.view)
sv.session_buffer.do_document_diagnostic_async(sv.view, ignore_pending=True)
for sv in not_visible_session_views:
sv.session_buffer.set_document_diagnostic_pending_refresh()

Expand Down
6 changes: 4 additions & 2 deletions plugin/session_buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,9 @@ def update_document_link(self, new_link: DocumentLink) -> None:

# --- textDocument/diagnostic --------------------------------------------------------------------------------------

def do_document_diagnostic_async(self, view: sublime.View, version: int | None = None) -> None:
def do_document_diagnostic_async(
self, view: sublime.View, version: int | None = None, ignore_pending: bool = False
) -> None:
mgr = self.session.manager()
if not mgr or not self.has_capability("diagnosticProvider"):
return
Expand All @@ -496,7 +498,7 @@ def do_document_diagnostic_async(self, view: sublime.View, version: int | None =
if version is None:
version = view.change_count()
if self._document_diagnostic_pending_request:
if self._document_diagnostic_pending_request.version == version:
if self._document_diagnostic_pending_request.version == version and not ignore_pending:
return
self.session.cancel_request(self._document_diagnostic_pending_request.request_id)
params: DocumentDiagnosticParams = {'textDocument': text_document_identifier(view)}
Expand Down

0 comments on commit a74d521

Please sign in to comment.