Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: adapt to API changes in LSP #113

Merged
merged 1 commit into from
Jan 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions plugin_commands.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .plugin import RustAnalyzerCommand
from LSP.plugin import apply_text_edits
from LSP.plugin import Request
from LSP.plugin.core.protocol import Error
from LSP.plugin.core.protocol import Range
Expand All @@ -7,7 +8,6 @@
from LSP.plugin.core.typing import List, TypedDict, Union
from LSP.plugin.core.views import region_to_range
from LSP.plugin.core.views import text_document_identifier
from LSP.plugin.formatting import apply_text_edits_to_view
import sublime


Expand Down Expand Up @@ -45,12 +45,9 @@ def make_request_async(self) -> None:
session.send_request_task(request).then(lambda result: self.on_result_async(result, document_version))

def on_result_async(self, edits: Union[JoinLinesRequest.ReturnType, Error], document_version: int) -> None:
if document_version != self.view.change_count():
return
if isinstance(edits, Error):
print('[{}] Error handling the "{}" request. Falling back to native join.'.format(
self.session_name, JoinLinesRequest.Type))
self.view.run_command('join_lines')
return
if edits:
apply_text_edits_to_view(edits, self.view)
apply_text_edits(self.view, edits, required_view_version=document_version)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice to see when lines like this get removed