diff --git a/plugin/core/constants.py b/plugin/core/constants.py index e8a84f34e..5fc4fbfa5 100644 --- a/plugin/core/constants.py +++ b/plugin/core/constants.py @@ -11,6 +11,7 @@ ST_VERSION = int(sublime.version()) +ST_PLATFORM = sublime.platform() # Keys for View.add_regions HOVER_HIGHLIGHT_KEY = 'lsp_hover_highlight' diff --git a/plugin/session_buffer.py b/plugin/session_buffer.py index 68f1828e8..97a0d4a15 100644 --- a/plugin/session_buffer.py +++ b/plugin/session_buffer.py @@ -1,5 +1,6 @@ from .core.constants import DOCUMENT_LINK_FLAGS from .core.constants import SEMANTIC_TOKEN_FLAGS +from .core.constants import ST_PLATFORM from .core.protocol import ColorInformation from .core.protocol import Diagnostic from .core.protocol import DocumentDiagnosticParams @@ -168,7 +169,8 @@ def _check_did_open(self, view: sublime.View) -> None: def _check_did_close(self, view: sublime.View) -> None: if self.opened and self.should_notify_did_close(): - self.purge_changes_async(view, suppress_requests=True) + if ST_PLATFORM != 'linux': # https://github.com/sublimelsp/LSP/pull/2438 + self.purge_changes_async(view, suppress_requests=True) self.session.send_notification(did_close(uri=self._last_known_uri)) self.opened = False diff --git a/tests/test_single_document.py b/tests/test_single_document.py index 4ac3b4255..8a655a97c 100644 --- a/tests/test_single_document.py +++ b/tests/test_single_document.py @@ -9,6 +9,8 @@ from setup import YieldPromise import os import sublime +import sys +import unittest try: @@ -406,6 +408,9 @@ class AnotherDocumentTestCase(TextDocumentTestCase): def get_test_name(cls) -> str: return "testfile2" + # The fix from https://github.com/sublimelsp/LSP/pull/2438 oddly causes an unrelated test to fail on Linux, so it's + # only applied on Windows and macOS for now. + @unittest.skipIf(sys.platform.startswith("linux"), "not working as expected on Linux") def test_did_change_before_did_close(self) -> 'Generator': assert self.view self.view.window().run_command("chain", {