diff --git a/internal/lsp/cache/session.go b/internal/lsp/cache/session.go index bcf7232ee9..a4394a2e93 100644 --- a/internal/lsp/cache/session.go +++ b/internal/lsp/cache/session.go @@ -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) diff --git a/internal/lsp/source/view.go b/internal/lsp/source/view.go index cc9511daf4..ddf8f6b477 100644 --- a/internal/lsp/source/view.go +++ b/internal/lsp/source/view.go @@ -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 diff --git a/internal/lsp/text_synchronization.go b/internal/lsp/text_synchronization.go index d08d25f7ab..745b5bcb8d 100644 --- a/internal/lsp/text_synchronization.go +++ b/internal/lsp/text_synchronization.go @@ -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