File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -337,7 +337,9 @@ func (s *server) DidClose(
337337 ctx context.Context ,
338338 params * protocol.DidCloseTextDocumentParams ,
339339) error {
340- s .fileManager .Close (ctx , params .TextDocument .URI )
340+ if file := s .fileManager .Get (params .TextDocument .URI ); file != nil {
341+ file .Close (ctx )
342+ }
341343 return nil
342344}
343345
Original file line number Diff line number Diff line change @@ -48,8 +48,11 @@ func newWorkspaceManager(lsp *lsp) *workspaceManager {
4848// LeaseWorkspace attempts to find and lease the workspace for the given URI string. If the
4949// workspace has not been seen before, a new workspace is created. This may fail.
5050func (w * workspaceManager ) LeaseWorkspace (ctx context.Context , uri protocol.URI ) (* workspace , error ) {
51- // Run a cleanup as a lazy job.
52- defer w .Cleanup (ctx )
51+ defer func () {
52+ // Run a cleanup as a lazy job.
53+ w .Cleanup (ctx )
54+ w .lsp .logger .Debug ("workspace: lease workspace" , slog .Int ("active" , len (w .workspaces )))
55+ }()
5356
5457 workspace , err := w .getOrCreateWorkspace (ctx , uri )
5558 if err != nil {
@@ -81,7 +84,7 @@ func (w *workspaceManager) Cleanup(ctx context.Context) {
8184func (w * workspaceManager ) getOrCreateWorkspace (ctx context.Context , uri protocol.URI ) (* workspace , error ) {
8285 // This looks for a workspace that already has ownership over the URI.
8386 // If a new file is added we will create a new workspace.
84- // Reusing workspaces is an optimization
87+ // Reusing workspaces is an optimization. Matching is on best-effort.
8588 fileName := uri .Filename ()
8689 for _ , workspace := range w .workspaces {
8790 if _ , ok := workspace .fileNameToFileInfo [fileName ]; ok {
You can’t perform that action at this time.
0 commit comments