Skip to content

Commit

Permalink
langserver: Avoid re-processing open files on didChangeWatchedFiles
Browse files Browse the repository at this point in the history
  • Loading branch information
radeksimko committed Sep 1, 2023
1 parent d730e72 commit 43817b8
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions internal/langserver/handlers/did_change_watched_files.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,20 @@ func (svc *service) DidChangeWatchedFiles(ctx context.Context, params lsp.DidCha
}

if change.Type == protocol.Changed {
// Check if document is open and skip running any jobs
// as we already did so as part of textDocument/didChange
// which clients should always send for *open* documents
// even if they change outside of the IDE.
docHandle := document.HandleFromURI(rawURI)
isOpen, err := svc.stateStore.DocumentStore.IsDocumentOpen(docHandle)
if err != nil {
svc.logger.Printf("error when checking open document (%q changed): %s", rawURI, err)
}
if isOpen {
svc.logger.Printf("document is open - ignoring event for %q", rawURI)
continue
}

ph, err := modHandleFromRawOsPath(ctx, rawPath)
if err != nil {
if err == ErrorSkip {
Expand Down

0 comments on commit 43817b8

Please sign in to comment.