Handle launch erroring

This commit is contained in:
itdominator 2024-09-08 00:32:09 -05:00
parent 9bf78ed559
commit ed63067bb8
2 changed files with 27 additions and 7 deletions

View File

@ -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) )

View File

@ -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: