diff --git a/src/core/widgets/buttons/bottom_button_box.py b/src/core/widgets/buttons/bottom_button_box.py index 9a0ed64..0aa94c5 100644 --- a/src/core/widgets/buttons/bottom_button_box.py +++ b/src/core/widgets/buttons/bottom_button_box.py @@ -105,6 +105,11 @@ class BottomButtonBox(Gtk.Box): def full_init(self, button, eve = None): button.hide() self.start_stop_lsp(self.start_stop_lsp_btn) + + if not hasattr(self.get_parent(), "lsp_process"): + self.rest_buttons() + return + self.send_initialize_message(self.initialize_btn) self.send_initialized_message(self.initialized_btn) @@ -117,4 +122,4 @@ class BottomButtonBox(Gtk.Box): self.request_btn.hide() self.full_init_btn.show() - self.start_stop_lsp_btn.set_image( Gtk.Image.new_from_icon_name("gtk-media-play", Gtk.IconSize.BUTTON) ) + self.start_stop_lsp_btn.set_image( Gtk.Image.new_from_icon_name("gtk-media-play", Gtk.IconSize.BUTTON) ) \ No newline at end of file diff --git a/src/core/widgets/lsp_message_box.py b/src/core/widgets/lsp_message_box.py index bc878d5..4c1dc84 100644 --- a/src/core/widgets/lsp_message_box.py +++ b/src/core/widgets/lsp_message_box.py @@ -120,7 +120,7 @@ class LSPMessageBox(Gtk.Box): self._send_message( LSPRequest(self._message_id, method, params) ) def _send_message(self, data: LSPRequest or LSPNotification): - if not data: return + if not data or not hasattr(self, "lsp_process"): return message_str = json.dumps(data, cls = MessageEncoder) message_size = len(message_str) @@ -163,11 +163,24 @@ class LSPMessageBox(Gtk.Box): # _command: str = parent.command_entry.get_text() # _command: str = parent.socket_entry.get_text() command: [] = _command.split() if len( _command.split() ) > 0 else [ _command ] - self.lsp_process = subprocess.Popen( - command, - stdout = subprocess.PIPE, - stdin = subprocess.PIPE - ) + try: + self.lsp_process = subprocess.Popen( + command, + stdout = subprocess.PIPE, + stdin = subprocess.PIPE + ) + except Exception as e: + self.bottom_buttons.rest_buttons() + self.get_parent().log_list.add_log_entry( + "LSP Client Error", + LSPResponse( + None, + { + "error": repr(e) + } + ) + ) + return return self.lsp_process.pid @@ -183,6 +196,8 @@ class LSPMessageBox(Gtk.Box): # Virtually this whole method unabashedly taken from ^ ... @daemon_threaded def _monitor_lsp_response(self): + if not hasattr(self, "lsp_process"): return + with self.read_lock: message_size = None while True: