Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

langserver: Avoid re-processing open files after file saving #1372

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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