on main help sign in
fix(lsp): properly remove clients from map on stop/kill
7ac4061Andrey Nering
internal/lsp/manager.go+3−2
@@ -201,13 +201,12 @@ func (s *Manager) startServer(ctx context.Context, name, filepath string, server
201 }()
201 }()
202
202
203 switch client.GetServerState() {
203 switch client.GetServerState() {
204− case StateReady, StateStarting:
204+ case StateReady, StateStarting, StateDisabled:
205 // already done, return
205 // already done, return
206 return
206 return
207 }
207 }
208
208
209 client.serverState.Store(StateStarting)
209 client.serverState.Store(StateStarting)
210− s.callback(name, client)
211
210
212 initCtx, cancel := context.WithTimeout(ctx, time.Duration(cmp.Or(cfg.Timeout, 30))*time.Second)
211 initCtx, cancel := context.WithTimeout(ctx, time.Duration(cmp.Or(cfg.Timeout, 30))*time.Second)
213 defer cancel()
212 defer cancel()
@@ -315,6 +314,7 @@ func (s *Manager) KillAll(context.Context) {
315 defer func() { s.callback(name, client) }()
314 defer func() { s.callback(name, client) }()
316 client.client.Kill()
315 client.client.Kill()
317 client.SetServerState(StateStopped)
316 client.SetServerState(StateStopped)
317+ s.clients.Del(name)
318 slog.Debug("Killed LSP client", "name", name)
318 slog.Debug("Killed LSP client", "name", name)
319 })
319 })
320 }
320 }
@@ -335,6 +335,7 @@ func (s *Manager) StopAll(ctx context.Context) {
335 slog.Warn("Failed to stop LSP client", "name", name, "error", err)
335 slog.Warn("Failed to stop LSP client", "name", name, "error", err)
336 }
336 }
337 client.SetServerState(StateStopped)
337 client.SetServerState(StateStopped)
338+ s.clients.Del(name)
338 slog.Debug("Stopped LSP client", "name", name)
339 slog.Debug("Stopped LSP client", "name", name)
339 })
340 })
340 }
341 }