From d972b93b646e969df01db014c257d32eabba7b3d Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Fri, 20 Sep 2024 00:59:35 -0500 Subject: [PATCH] fixed id updates; improved result checking --- .../base/notebook/editor_controller.py | 24 +++++++++++-------- .../base/sourceview/source_view_events.py | 4 ++-- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/core/widgets/base/notebook/editor_controller.py b/src/core/widgets/base/notebook/editor_controller.py index 853d50a..91fa84e 100644 --- a/src/core/widgets/base/notebook/editor_controller.py +++ b/src/core/widgets/base/notebook/editor_controller.py @@ -38,7 +38,7 @@ class EditorControllerMixin(KeyInputController, EditorEventsMixin): if action == "set_buffer_style": self.set_buffer_style(source_view, query) - def _handle_lsp_message(self, message: dict or LSPResponseTypes): + def _handle_lsp_message(self, message: dict or LSPResponseType): if not self.is_editor_focused: return # TODO: Find way to converge this page_num, container, source_view = self.get_active_view() page_num = None @@ -50,18 +50,22 @@ class EditorControllerMixin(KeyInputController, EditorEventsMixin): ... if hasattr(message, "result"): - keys = message.result.keys() + if message.result is dict: + keys = message.result.keys() - if "items" in keys: - completion = source_view.get_completion() - providers = completion.get_providers() + if "items" in keys: + completion = source_view.get_completion() + providers = completion.get_providers() - for provider in providers: - if provider.__class__.__name__ == 'LSPCompletionProvider': - source_view.completion_items = message.result["items"] - source_view.emit("show-completion") + for provider in providers: + if provider.__class__.__name__ == 'LSPCompletionProvider': + source_view.completion_items = message.result["items"] + source_view.emit("show-completion") - if "result" in keys: + if "result" in keys: + ... + + if message.result is list: ... if hasattr(message, "method"): diff --git a/src/core/widgets/base/sourceview/source_view_events.py b/src/core/widgets/base/sourceview/source_view_events.py index 0b3ce78..e462a1d 100644 --- a/src/core/widgets/base/sourceview/source_view_events.py +++ b/src/core/widgets/base/sourceview/source_view_events.py @@ -26,11 +26,11 @@ class SourceViewEvents(SourceViewDnDMixin, MarkEventsMixin, FileEventsMixin): if not self._loading_file: buffer.version_id = self._version_id + self._version_id += 1 event_system.emit("buffer_changed", (buffer, )) event_system.emit("textDocument/didChange", (file_type, self.get_current_file().get_uri(), buffer, )) - - self._version_id += 1 + # event_system.emit("textDocument/completion", (self, )) self.update_cursor_position(buffer)