From 0c65595b8efaca4ba8d7167a428ac5d70de8aea6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Ch=C5=82odnicki?= Date: Sun, 21 Jan 2024 22:58:23 +0100 Subject: [PATCH] refactor: adapt to API changes in LSP (#113) --- plugin_commands.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/plugin_commands.py b/plugin_commands.py index b6ead16..3db8573 100644 --- a/plugin_commands.py +++ b/plugin_commands.py @@ -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 @@ -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 @@ -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)