From 9c9493a7acc2428614f51c5c34a7168f8781902f Mon Sep 17 00:00:00 2001 From: Janos Wortmann Date: Mon, 25 Mar 2024 22:29:28 +0100 Subject: [PATCH 01/14] Ensure didChange is never sent after didClose This fixes for example the Pyright warning LSP-pyright: Received change text document command for closed file when a file is saved and closed immediately after changes were applied. --- plugin/session_buffer.py | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/plugin/session_buffer.py b/plugin/session_buffer.py index 71febb56b..56bc403a9 100644 --- a/plugin/session_buffer.py +++ b/plugin/session_buffer.py @@ -166,8 +166,9 @@ def _check_did_open(self, view: sublime.View) -> None: self._do_document_link_async(view, version) self.session.notify_plugin_on_session_buffer_change(self) - def _check_did_close(self) -> None: + def _check_did_close(self, view: sublime.View) -> None: if self.opened and self.should_notify_did_close(): + self.purge_changes_async(view) self.session.send_notification(did_close(uri=self._last_known_uri)) self.opened = False @@ -202,9 +203,9 @@ def remove_session_view(self, sv: SessionViewProtocol) -> None: self._clear_semantic_token_regions(sv.view) self.session_views.remove(sv) if len(self.session_views) == 0: - self._on_before_destroy() + self._on_before_destroy(sv.view) - def _on_before_destroy(self) -> None: + def _on_before_destroy(self, view: sublime.View) -> None: self.remove_all_inlay_hints() if self.has_capability("diagnosticProvider") and self.session.config.diagnostics_mode == "open_files": self.session.m_textDocument_publishDiagnostics({'uri': self._last_known_uri, 'diagnostics': []}) @@ -216,7 +217,7 @@ def _on_before_destroy(self) -> None: # in unregistering ourselves from the session. if not self.session.exiting: # Only send textDocument/didClose when we are the only view left (i.e. there are no other clones). - self._check_did_close() + self._check_did_close(view) self.session.unregister_session_buffer_async(self) def register_capability_async( @@ -308,7 +309,7 @@ def on_revert_async(self, view: sublime.View) -> None: on_reload_async = on_revert_async - def purge_changes_async(self, view: sublime.View) -> None: + def purge_changes_async(self, view: sublime.View, suppress_requests: bool = False) -> None: if self._pending_changes is None: return sync_kind = self.text_sync_kind() @@ -316,7 +317,7 @@ def purge_changes_async(self, view: sublime.View) -> None: return if sync_kind == TextDocumentSyncKind.Full: changes = None - version = view.change_count() + version = view.change_count() if view.is_valid() else self._pending_changes.version else: changes = self._pending_changes.changes version = self._pending_changes.version @@ -329,12 +330,14 @@ def purge_changes_async(self, view: sublime.View) -> None: finally: self._pending_changes = None self.session.notify_plugin_on_session_buffer_change(self) - sublime.set_timeout_async(lambda: self._on_after_change_async(view, version)) + sublime.set_timeout_async(lambda: self._on_after_change_async(view, version, suppress_requests)) - def _on_after_change_async(self, view: sublime.View, version: int) -> None: + def _on_after_change_async(self, view: sublime.View, version: int, suppress_requests: bool = False) -> None: if self._is_saving: self._has_changed_during_save = True return + if suppress_requests or not view.is_valid(): + return self._do_color_boxes_async(view, version) self.do_document_diagnostic_async(view, version) if self.session.config.diagnostics_mode == "workspace" and \ @@ -357,7 +360,7 @@ def on_pre_save_async(self, view: sublime.View) -> None: def on_post_save_async(self, view: sublime.View, new_uri: DocumentUri) -> None: self._is_saving = False if new_uri != self._last_known_uri: - self._check_did_close() + self._check_did_close(view) self._last_known_uri = new_uri self._check_did_open(view) else: From ba364a78d6ef2f086d1d4c7caea77889550307ab Mon Sep 17 00:00:00 2001 From: Janos Wortmann Date: Tue, 26 Mar 2024 17:19:26 +0100 Subject: [PATCH 02/14] Missed something --- plugin/session_buffer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/session_buffer.py b/plugin/session_buffer.py index 56bc403a9..deb5f85c5 100644 --- a/plugin/session_buffer.py +++ b/plugin/session_buffer.py @@ -168,7 +168,7 @@ 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) + self.purge_changes_async(view, suppress_requests=True) self.session.send_notification(did_close(uri=self._last_known_uri)) self.opened = False From c211f9962ff432e45caab4846488d42fb5a288f1 Mon Sep 17 00:00:00 2001 From: Janos Wortmann Date: Sat, 30 Mar 2024 22:50:11 +0100 Subject: [PATCH 03/14] Add test --- tests/test_single_document.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test_single_document.py b/tests/test_single_document.py index 4d1bb10d3..d48083157 100644 --- a/tests/test_single_document.py +++ b/tests/test_single_document.py @@ -109,6 +109,19 @@ def test_did_change(self) -> 'Generator': } }) + def test_did_change_before_did_close(self) -> 'Generator': + assert self.view + self.view.window().run_command("chain", { + "commands": [ + ["insert", {"characters": "TEST"}], + ["save", {"async": False}], + ["close", {}] + ] + }) + yield from self.await_message('textDocument/didChange') + # yield from self.await_message('textDocument/didSave') # TODO why is this not sent? + yield from self.await_message('textDocument/didClose') + def test_sends_save_with_purge(self) -> 'Generator': assert self.view self.view.settings().set("lsp_format_on_save", False) From b8b0d9b1c47c50ab9fe66eb39f0d3a36fb9b761c Mon Sep 17 00:00:00 2001 From: Janos Wortmann Date: Sat, 30 Mar 2024 22:57:58 +0100 Subject: [PATCH 04/14] Maybe like this? --- tests/test_single_document.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/tests/test_single_document.py b/tests/test_single_document.py index d48083157..6f80dd644 100644 --- a/tests/test_single_document.py +++ b/tests/test_single_document.py @@ -109,19 +109,6 @@ def test_did_change(self) -> 'Generator': } }) - def test_did_change_before_did_close(self) -> 'Generator': - assert self.view - self.view.window().run_command("chain", { - "commands": [ - ["insert", {"characters": "TEST"}], - ["save", {"async": False}], - ["close", {}] - ] - }) - yield from self.await_message('textDocument/didChange') - # yield from self.await_message('textDocument/didSave') # TODO why is this not sent? - yield from self.await_message('textDocument/didClose') - def test_sends_save_with_purge(self) -> 'Generator': assert self.view self.view.settings().set("lsp_format_on_save", False) @@ -411,3 +398,19 @@ def test_will_save_wait_until(self) -> 'Generator': text = self.view.substr(sublime.Region(0, self.view.size())) self.assertEquals("BBB", text) yield from self.await_clear_view_and_save() + + +class AnotherDocumentTestCase(TextDocumentTestCase): + + def test_did_change_before_did_close(self) -> 'Generator': + assert self.view + self.view.window().run_command("chain", { + "commands": [ + ["insert", {"characters": "TEST"}], + ["save", {"async": False}], + ["close", {}] + ] + }) + yield from self.await_message('textDocument/didChange') + # yield from self.await_message('textDocument/didSave') # TODO why is this not sent? + yield from self.await_message('textDocument/didClose') From d430b9f943885a7e19c2b30a90c6f458cba6fa13 Mon Sep 17 00:00:00 2001 From: Janos Wortmann Date: Sat, 30 Mar 2024 23:09:23 +0100 Subject: [PATCH 05/14] Try something else --- tests/test_single_document.py | 4 ++++ tests/testfile2.txt | 0 2 files changed, 4 insertions(+) create mode 100644 tests/testfile2.txt diff --git a/tests/test_single_document.py b/tests/test_single_document.py index 6f80dd644..4ac3b4255 100644 --- a/tests/test_single_document.py +++ b/tests/test_single_document.py @@ -402,6 +402,10 @@ def test_will_save_wait_until(self) -> 'Generator': class AnotherDocumentTestCase(TextDocumentTestCase): + @classmethod + def get_test_name(cls) -> str: + return "testfile2" + def test_did_change_before_did_close(self) -> 'Generator': assert self.view self.view.window().run_command("chain", { diff --git a/tests/testfile2.txt b/tests/testfile2.txt new file mode 100644 index 000000000..e69de29bb From 0fc0e1e67817ea366acaac89942ccdc39c2a0a7e Mon Sep 17 00:00:00 2001 From: Janos Wortmann Date: Sun, 31 Mar 2024 20:40:07 +0200 Subject: [PATCH 06/14] Simplify expression to save one unnecessary API call view.change_count() returns 0 if the view isn't valid anymore (closed), so we can simply use short-circuit evaluation for this and don't need the is_valid() API call. --- plugin/session_buffer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/session_buffer.py b/plugin/session_buffer.py index deb5f85c5..68f1828e8 100644 --- a/plugin/session_buffer.py +++ b/plugin/session_buffer.py @@ -317,7 +317,7 @@ def purge_changes_async(self, view: sublime.View, suppress_requests: bool = Fals return if sync_kind == TextDocumentSyncKind.Full: changes = None - version = view.change_count() if view.is_valid() else self._pending_changes.version + version = view.change_count() or self._pending_changes.version else: changes = self._pending_changes.changes version = self._pending_changes.version From 4dd2e91ee9f9bc6bf8b93082b5be4df7243b0c75 Mon Sep 17 00:00:00 2001 From: Janos Wortmann Date: Thu, 4 Apr 2024 13:22:47 +0200 Subject: [PATCH 07/14] Exempt Linux --- plugin/core/constants.py | 1 + plugin/session_buffer.py | 4 +++- tests/test_single_document.py | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) 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", { From aca100ea67129a73b77e406e03ef839e1f7650bf Mon Sep 17 00:00:00 2001 From: Janos Wortmann Date: Sun, 7 Apr 2024 08:06:14 +0200 Subject: [PATCH 08/14] Small tweak to save an API call --- plugin/session_buffer.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/plugin/session_buffer.py b/plugin/session_buffer.py index 97a0d4a15..1fbbc1925 100644 --- a/plugin/session_buffer.py +++ b/plugin/session_buffer.py @@ -338,19 +338,22 @@ def _on_after_change_async(self, view: sublime.View, version: int, suppress_requ if self._is_saving: self._has_changed_during_save = True return - if suppress_requests or not view.is_valid(): + if suppress_requests: return - self._do_color_boxes_async(view, version) - self.do_document_diagnostic_async(view, version) - if self.session.config.diagnostics_mode == "workspace" and \ - not self.session.workspace_diagnostics_pending_response and \ - self.session.has_capability('diagnosticProvider.workspaceDiagnostics'): - self._workspace_diagnostics_debouncer_async.debounce( - self.session.do_workspace_diagnostics_async, timeout_ms=WORKSPACE_DIAGNOSTICS_TIMEOUT) - self.do_semantic_tokens_async(view) - if userprefs().link_highlight_style in ("underline", "none"): - self._do_document_link_async(view, version) - self.do_inlay_hints_async(view) + try: + self._do_color_boxes_async(view, version) + self.do_document_diagnostic_async(view, version) + if self.session.config.diagnostics_mode == "workspace" and \ + not self.session.workspace_diagnostics_pending_response and \ + self.session.has_capability('diagnosticProvider.workspaceDiagnostics'): + self._workspace_diagnostics_debouncer_async.debounce( + self.session.do_workspace_diagnostics_async, timeout_ms=WORKSPACE_DIAGNOSTICS_TIMEOUT) + self.do_semantic_tokens_async(view) + if userprefs().link_highlight_style in ("underline", "none"): + self._do_document_link_async(view, version) + self.do_inlay_hints_async(view) + except MissingUriError: + pass def on_pre_save_async(self, view: sublime.View) -> None: self._is_saving = True From 740c0cbf0cbd506259de7c93704a91318bb52942 Mon Sep 17 00:00:00 2001 From: Janos Wortmann Date: Wed, 10 Apr 2024 18:41:10 +0200 Subject: [PATCH 09/14] Revert "Exempt Linux" This reverts commit 4dd2e91ee9f9bc6bf8b93082b5be4df7243b0c75. --- plugin/core/constants.py | 1 - plugin/session_buffer.py | 4 +--- tests/test_single_document.py | 5 ----- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/plugin/core/constants.py b/plugin/core/constants.py index 5fc4fbfa5..e8a84f34e 100644 --- a/plugin/core/constants.py +++ b/plugin/core/constants.py @@ -11,7 +11,6 @@ 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 1fbbc1925..e2c6907de 100644 --- a/plugin/session_buffer.py +++ b/plugin/session_buffer.py @@ -1,6 +1,5 @@ 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 @@ -169,8 +168,7 @@ 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(): - if ST_PLATFORM != 'linux': # https://github.com/sublimelsp/LSP/pull/2438 - self.purge_changes_async(view, suppress_requests=True) + 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 8a655a97c..4ac3b4255 100644 --- a/tests/test_single_document.py +++ b/tests/test_single_document.py @@ -9,8 +9,6 @@ from setup import YieldPromise import os import sublime -import sys -import unittest try: @@ -408,9 +406,6 @@ 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", { From dd66a6acc304d50e69dcd444e0acb8db2166a96c Mon Sep 17 00:00:00 2001 From: Janos Wortmann Date: Wed, 10 Apr 2024 18:47:39 +0200 Subject: [PATCH 10/14] Fix failing test on Linux --- tests/test_single_document.py | 93 ++++++++++++++++++----------------- 1 file changed, 48 insertions(+), 45 deletions(-) diff --git a/tests/test_single_document.py b/tests/test_single_document.py index 4ac3b4255..673f1842f 100644 --- a/tests/test_single_document.py +++ b/tests/test_single_document.py @@ -84,31 +84,6 @@ def test_did_close(self) -> 'Generator': self.view.close() yield from self.await_message("textDocument/didClose") - def test_did_change(self) -> 'Generator': - assert self.view - self.maxDiff = None - self.insert_characters("A") - yield from self.await_message("textDocument/didChange") - # multiple changes are batched into one didChange notification - self.insert_characters("B\n") - self.insert_characters("🙂\n") - self.insert_characters("D") - promise = YieldPromise() - yield from self.await_message("textDocument/didChange", promise) - self.assertEqual(promise.result(), { - 'contentChanges': [ - {'rangeLength': 0, 'range': {'start': {'line': 0, 'character': 1}, 'end': {'line': 0, 'character': 1}}, 'text': 'B'}, # noqa - {'rangeLength': 0, 'range': {'start': {'line': 0, 'character': 2}, 'end': {'line': 0, 'character': 2}}, 'text': '\n'}, # noqa - {'rangeLength': 0, 'range': {'start': {'line': 1, 'character': 0}, 'end': {'line': 1, 'character': 0}}, 'text': '🙂'}, # noqa - # Note that this is character offset (2) is correct (UTF-16). - {'rangeLength': 0, 'range': {'start': {'line': 1, 'character': 2}, 'end': {'line': 1, 'character': 2}}, 'text': '\n'}, # noqa - {'rangeLength': 0, 'range': {'start': {'line': 2, 'character': 0}, 'end': {'line': 2, 'character': 0}}, 'text': 'D'}], # noqa - 'textDocument': { - 'version': self.view.change_count(), - 'uri': filename_to_uri(TEST_FILE_PATH) - } - }) - def test_sends_save_with_purge(self) -> 'Generator': assert self.view self.view.settings().set("lsp_format_on_save", False) @@ -371,6 +346,54 @@ def test_progress(self) -> 'Generator': self.assertEqual(result, {"general": "kenobi"}) +class SingleDocumentTestCase2(TextDocumentTestCase): + + def test_did_change(self) -> 'Generator': + assert self.view + self.maxDiff = None + self.insert_characters("A") + yield from self.await_message("textDocument/didChange") + # multiple changes are batched into one didChange notification + self.insert_characters("B\n") + self.insert_characters("🙂\n") + self.insert_characters("D") + promise = YieldPromise() + yield from self.await_message("textDocument/didChange", promise) + self.assertEqual(promise.result(), { + 'contentChanges': [ + {'rangeLength': 0, 'range': {'start': {'line': 0, 'character': 1}, 'end': {'line': 0, 'character': 1}}, 'text': 'B'}, # noqa + {'rangeLength': 0, 'range': {'start': {'line': 0, 'character': 2}, 'end': {'line': 0, 'character': 2}}, 'text': '\n'}, # noqa + {'rangeLength': 0, 'range': {'start': {'line': 1, 'character': 0}, 'end': {'line': 1, 'character': 0}}, 'text': '🙂'}, # noqa + # Note that this is character offset (2) is correct (UTF-16). + {'rangeLength': 0, 'range': {'start': {'line': 1, 'character': 2}, 'end': {'line': 1, 'character': 2}}, 'text': '\n'}, # noqa + {'rangeLength': 0, 'range': {'start': {'line': 2, 'character': 0}, 'end': {'line': 2, 'character': 0}}, 'text': 'D'}], # noqa + 'textDocument': { + 'version': self.view.change_count(), + 'uri': filename_to_uri(TEST_FILE_PATH) + } + }) + + +class SingleDocumentTestCase3(TextDocumentTestCase): + + @classmethod + def get_test_name(cls) -> str: + return "testfile2" + + def test_did_change_before_did_close(self) -> 'Generator': + assert self.view + self.view.window().run_command("chain", { + "commands": [ + ["insert", {"characters": "TEST"}], + ["save", {"async": False}], + ["close", {}] + ] + }) + yield from self.await_message('textDocument/didChange') + # yield from self.await_message('textDocument/didSave') # TODO why is this not sent? + yield from self.await_message('textDocument/didClose') + + class WillSaveWaitUntilTestCase(TextDocumentTestCase): @classmethod @@ -398,23 +421,3 @@ def test_will_save_wait_until(self) -> 'Generator': text = self.view.substr(sublime.Region(0, self.view.size())) self.assertEquals("BBB", text) yield from self.await_clear_view_and_save() - - -class AnotherDocumentTestCase(TextDocumentTestCase): - - @classmethod - def get_test_name(cls) -> str: - return "testfile2" - - def test_did_change_before_did_close(self) -> 'Generator': - assert self.view - self.view.window().run_command("chain", { - "commands": [ - ["insert", {"characters": "TEST"}], - ["save", {"async": False}], - ["close", {}] - ] - }) - yield from self.await_message('textDocument/didChange') - # yield from self.await_message('textDocument/didSave') # TODO why is this not sent? - yield from self.await_message('textDocument/didClose') From 43ede82dba41c96e26c035bd4809ef6714782304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D1=80=D0=B5=D0=B4=D1=80=D0=B0=D0=B3=20=D0=9D=D0=B8?= =?UTF-8?q?=D0=BA=D0=BE=D0=BB=D0=B8=D1=9B?= Date: Fri, 12 Apr 2024 11:59:48 +0200 Subject: [PATCH 11/14] actually this test passes locally with this line uncommented --- tests/test_single_document.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_single_document.py b/tests/test_single_document.py index 673f1842f..64d76e85e 100644 --- a/tests/test_single_document.py +++ b/tests/test_single_document.py @@ -390,7 +390,7 @@ def test_did_change_before_did_close(self) -> 'Generator': ] }) yield from self.await_message('textDocument/didChange') - # yield from self.await_message('textDocument/didSave') # TODO why is this not sent? + yield from self.await_message('textDocument/didSave') yield from self.await_message('textDocument/didClose') From b5ee72eae57baefe4f9d4876611fce7591824060 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D1=80=D0=B5=D0=B4=D1=80=D0=B0=D0=B3=20=D0=9D=D0=B8?= =?UTF-8?q?=D0=BA=D0=BE=D0=BB=D0=B8=D1=9B?= Date: Fri, 12 Apr 2024 12:03:49 +0200 Subject: [PATCH 12/14] Revert, apparently it fails on the CI... This reverts commit 43ede82dba41c96e26c035bd4809ef6714782304. --- tests/test_single_document.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_single_document.py b/tests/test_single_document.py index 64d76e85e..673f1842f 100644 --- a/tests/test_single_document.py +++ b/tests/test_single_document.py @@ -390,7 +390,7 @@ def test_did_change_before_did_close(self) -> 'Generator': ] }) yield from self.await_message('textDocument/didChange') - yield from self.await_message('textDocument/didSave') + # yield from self.await_message('textDocument/didSave') # TODO why is this not sent? yield from self.await_message('textDocument/didClose') From 11c5ecbc82423bbcd8f08dc7243b3c20141a5fc7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D1=80=D0=B5=D0=B4=D1=80=D0=B0=D0=B3=20=D0=9D=D0=B8?= =?UTF-8?q?=D0=BA=D0=BE=D0=BB=D0=B8=D1=9B?= Date: Fri, 12 Apr 2024 12:18:30 +0200 Subject: [PATCH 13/14] try a slightly different approach just to see... test pass locally --- tests/test_single_document.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/tests/test_single_document.py b/tests/test_single_document.py index 673f1842f..b2988fb34 100644 --- a/tests/test_single_document.py +++ b/tests/test_single_document.py @@ -382,15 +382,11 @@ def get_test_name(cls) -> str: def test_did_change_before_did_close(self) -> 'Generator': assert self.view - self.view.window().run_command("chain", { - "commands": [ - ["insert", {"characters": "TEST"}], - ["save", {"async": False}], - ["close", {}] - ] - }) + self.insert_characters("TEST") + self.view.window().run_command("save", {'async': False}) + self.view.window().run_command("close", {}) yield from self.await_message('textDocument/didChange') - # yield from self.await_message('textDocument/didSave') # TODO why is this not sent? + yield from self.await_message('textDocument/didSave') yield from self.await_message('textDocument/didClose') From 2b5f56f2e25496a17d377b01f613aae63622bad1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9F=D1=80=D0=B5=D0=B4=D1=80=D0=B0=D0=B3=20=D0=9D=D0=B8?= =?UTF-8?q?=D0=BA=D0=BE=D0=BB=D0=B8=D1=9B?= Date: Fri, 12 Apr 2024 12:21:17 +0200 Subject: [PATCH 14/14] Revert "try a slightly different approach just to see... test pass locally" the test still fail on the CI This reverts commit 11c5ecbc82423bbcd8f08dc7243b3c20141a5fc7. --- tests/test_single_document.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tests/test_single_document.py b/tests/test_single_document.py index b2988fb34..673f1842f 100644 --- a/tests/test_single_document.py +++ b/tests/test_single_document.py @@ -382,11 +382,15 @@ def get_test_name(cls) -> str: def test_did_change_before_did_close(self) -> 'Generator': assert self.view - self.insert_characters("TEST") - self.view.window().run_command("save", {'async': False}) - self.view.window().run_command("close", {}) + self.view.window().run_command("chain", { + "commands": [ + ["insert", {"characters": "TEST"}], + ["save", {"async": False}], + ["close", {}] + ] + }) yield from self.await_message('textDocument/didChange') - yield from self.await_message('textDocument/didSave') + # yield from self.await_message('textDocument/didSave') # TODO why is this not sent? yield from self.await_message('textDocument/didClose')