mirror of https://github.com/golang/go.git
internal/lsp: update modifications to directories at the LSP level
Expanding the set of modifications in the cache package leads to a mismatch when the didModifyFiles code in text_synchronization.go processes the list of modifications. Change-Id: Id0b7fea445103b34838fb9b03aee95a01e454306 Reviewed-on: https://go-review.googlesource.com/c/tools/+/274192 Trust: Rebecca Stambler <rstambler@golang.org> Run-TryBot: Rebecca Stambler <rstambler@golang.org> gopls-CI: kokoro <noreply+kokoro@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Heschi Kreinick <heschi@google.com>
This commit is contained in:
parent
bd313628b4
commit
7e522c867c
|
|
@ -422,10 +422,6 @@ func (s *Session) DidModifyFiles(ctx context.Context, changes []source.FileModif
|
|||
views := make(map[*View]map[span.URI]*fileChange)
|
||||
bestViews := map[span.URI]source.View{}
|
||||
|
||||
// If the set of changes included directories, expand those directories
|
||||
// to their files.
|
||||
changes = s.expandChangesToDirectories(ctx, changes)
|
||||
|
||||
overlays, err := s.updateOverlays(ctx, changes)
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
|
|
@ -498,9 +494,7 @@ func (s *Session) DidModifyFiles(ctx context.Context, changes []source.FileModif
|
|||
return bestViews, snapshots, releases, nil
|
||||
}
|
||||
|
||||
// expandChangesToDirectories returns the set of changes with the directory
|
||||
// changes removed and expanded to include all of the files in the directory.
|
||||
func (s *Session) expandChangesToDirectories(ctx context.Context, changes []source.FileModification) []source.FileModification {
|
||||
func (s *Session) ExpandModificationsToDirectories(ctx context.Context, changes []source.FileModification) []source.FileModification {
|
||||
var snapshots []*snapshot
|
||||
for _, v := range s.views {
|
||||
snapshot, release := v.getSnapshot(ctx)
|
||||
|
|
|
|||
|
|
@ -289,6 +289,11 @@ type Session interface {
|
|||
// resulting snapshots, a guaranteed one per view.
|
||||
DidModifyFiles(ctx context.Context, changes []FileModification) (map[span.URI]View, map[View]Snapshot, []func(), error)
|
||||
|
||||
// ExpandModificationsToDirectories returns the set of changes with the
|
||||
// directory changes removed and expanded to include all of the files in
|
||||
// the directory.
|
||||
ExpandModificationsToDirectories(ctx context.Context, changes []FileModification) []FileModification
|
||||
|
||||
// Overlays returns a slice of file overlays for the session.
|
||||
Overlays() []Overlay
|
||||
|
||||
|
|
|
|||
|
|
@ -186,6 +186,11 @@ func (s *Server) didModifyFiles(ctx context.Context, modifications []source.File
|
|||
}()
|
||||
}()
|
||||
}
|
||||
|
||||
// If the set of changes included directories, expand those directories
|
||||
// to their files.
|
||||
modifications = s.session.ExpandModificationsToDirectories(ctx, modifications)
|
||||
|
||||
views, snapshots, releases, err := s.session.DidModifyFiles(ctx, modifications)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
Loading…
Reference in New Issue