From 7ac4061b6c8af87e05edbf6bfaa94ded48315545 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Wed, 18 Feb 2026 14:19:49 -0300 Subject: [PATCH] fix(lsp): properly remove clients from map on stop/kill MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Delete clients from the map in StopAll and KillAll so they can be recreated on restart - Add StateDisabled to the state check to prevent re-initializing disabled clients - Remove duplicate callback invocation in startServer 💘 Generated with Crush Assisted-by: Kimi K2.5 via Crush --- internal/lsp/manager.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/lsp/manager.go b/internal/lsp/manager.go index 381700d1299454bd241aeeaf6525686e6c44d45c..44f04e9a6e005a9217b4f62e3f3b477f1ff85838 100644 --- a/internal/lsp/manager.go +++ b/internal/lsp/manager.go @@ -201,13 +201,12 @@ func (s *Manager) startServer(ctx context.Context, name, filepath string, server }() switch client.GetServerState() { - case StateReady, StateStarting: + case StateReady, StateStarting, StateDisabled: // already done, return return } client.serverState.Store(StateStarting) - s.callback(name, client) initCtx, cancel := context.WithTimeout(ctx, time.Duration(cmp.Or(cfg.Timeout, 30))*time.Second) defer cancel() @@ -315,6 +314,7 @@ func (s *Manager) KillAll(context.Context) { defer func() { s.callback(name, client) }() client.client.Kill() client.SetServerState(StateStopped) + s.clients.Del(name) slog.Debug("Killed LSP client", "name", name) }) } @@ -335,6 +335,7 @@ func (s *Manager) StopAll(ctx context.Context) { slog.Warn("Failed to stop LSP client", "name", name, "error", err) } client.SetServerState(StateStopped) + s.clients.Del(name) slog.Debug("Stopped LSP client", "name", name) }) }