@@ -319,30 +319,6 @@ func (c *Client) NotifyChange(ctx context.Context, filepath string) error {
319319 return c.client.NotifyDidChangeTextDocument(ctx, uri, int(fileInfo.Version), changes)
320320}
321321
322−// CloseFile closes a file in the LSP server.
323−//
324−// NOTE: this is only ever called on LSP shutdown.
325−func (c *Client) CloseFile(ctx context.Context, filepath string) error {
326− cfg := config.Get()
327− uri := string(protocol.URIFromPath(filepath))
328−
329− if _, exists := c.openFiles.Get(uri); !exists {
330− return nil // Already closed
331− }
332−
333− if cfg.Options.DebugLSP {
334− slog.Debug("Closing file", "file", filepath)
335− }
336−
337− if err := c.client.NotifyDidCloseTextDocument(ctx, uri); err != nil {
338− return err
339− }
340−
341− c.openFiles.Del(uri)
342−
343− return nil
344−}
345−
346322// IsFileOpen checks if a file is currently open.
347323func (c *Client) IsFileOpen(filepath string) bool {
348324 uri := string(protocol.URIFromPath(filepath))
@@ -353,29 +329,16 @@ func (c *Client) IsFileOpen(filepath string) bool {
353329// CloseAllFiles closes all currently open files.
354330func (c *Client) CloseAllFiles(ctx context.Context) {
355331 cfg := config.Get()
356− filesToClose := make([]string, 0, c.openFiles.Len())
357−
358− // First collect all URIs that need to be closed
332+ debugLSP := cfg != nil && cfg.Options.DebugLSP
359333 for uri := range c.openFiles.Seq2() {
360− // Convert URI back to file path using proper URI handling
361− filePath, err := protocol.DocumentURI(uri).Path()
362− if err != nil {
363− slog.Error("Failed to convert URI to path for file closing", "uri", uri, "error", err)
364− continue
334+ if debugLSP {
335+ slog.Debug("Closing file", "file", uri)
365336 }
366− filesToClose = append(filesToClose, filePath)
367− }
368−
369− // Then close them all
370− for _, filePath := range filesToClose {
371− err := c.CloseFile(ctx, filePath)
372− if err != nil && cfg != nil && cfg.Options.DebugLSP {
373− slog.Warn("Error closing file", "file", filePath, "error", err)
337+ if err := c.client.NotifyDidCloseTextDocument(ctx, uri); err != nil {
338+ slog.Warn("Error closing rile", "uri", uri, "error", err)
339+ continue
374340 }
375− }
376−
377− if cfg != nil && cfg.Options.DebugLSP {
378− slog.Debug("Closed all files", "files", filesToClose)
341+ c.openFiles.Del(uri)
379342 }
380343}
381344