1
0
mirror of https://github.com/golang/go synced 2024-09-30 22:48:32 -06:00

internal/lsp: ignore irrelevant on-disk changes

Change-Id: Ibdceadbfc822a64066d9370eefa9ff5f7988d0a2
Reviewed-on: https://go-review.googlesource.com/c/tools/+/219202
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Rebecca Stambler 2020-02-12 15:18:16 -05:00
parent ea181f53ac
commit 6dd6151793

View File

@ -392,16 +392,23 @@ func basename(filename string) string {
}
func (v *view) relevantChange(c source.FileModification) bool {
if v.contains(c.URI) {
return true
}
// If the file is known to the view, the change is relevant.
known := v.knownFile(c.URI)
// Check if the view is already aware of this file.
// If so, the change is relevant.
// If the file is not known to the view, and the change is only on-disk,
// we should not invalidate the snapshot. This is necessary because Emacs
// sends didChangeWatchedFiles events for temp files.
if !known && c.OnDisk && (c.Action == source.Change || c.Action == source.Delete) {
return false
}
return v.contains(c.URI) || known
}
func (v *view) knownFile(uri span.URI) bool {
v.mu.Lock()
defer v.mu.Unlock()
f, err := v.findFile(c.URI)
f, err := v.findFile(uri)
return f != nil && err == nil
}