@@ -156,8 +156,9 @@ type DenoProgramEntries struct {
156156}
157157
158158type DenoServerData struct {
159- programEntries DenoProgramEntries
160- documentCache map [lsproto.DocumentUri ]* lsproto.DenoDocumentData
159+ programEntries DenoProgramEntries
160+ documentCache map [lsproto.DocumentUri ]* lsproto.DenoDocumentData
161+ documentCacheMu sync.RWMutex
161162}
162163
163164type DenoLanguageServiceHost struct {
@@ -263,6 +264,8 @@ func (v *DenoVFS) GetDocument(path string) *lsproto.DenoDocumentData {
263264 } else {
264265 uri = lsconv .FileNameToDocumentURI (path )
265266 }
267+ v .server .deno .documentCacheMu .Lock ()
268+ defer v .server .deno .documentCacheMu .Unlock ()
266269 if v .server .deno .documentCache != nil {
267270 if data , ok := v .server .deno .documentCache [uri ]; ok {
268271 return data
@@ -1127,7 +1130,9 @@ func (s *Server) handleDenoRequest(ctx context.Context, params *lsproto.DenoRequ
11271130 if params .WorkspaceChange != nil {
11281131 if params .WorkspaceChange .NewConfiguration != nil {
11291132 // Clear document cache on new configuration
1133+ s .deno .documentCacheMu .Lock ()
11301134 s .deno .documentCache = make (map [lsproto.DocumentUri ]* lsproto.DenoDocumentData )
1135+ s .deno .documentCacheMu .Unlock ()
11311136
11321137 byCompilerOptionsKey := make (map [string ]* DenoProgramEntry , len (params .WorkspaceChange .NewConfiguration .ByCompilerOptionsKey ))
11331138 byNotebookUri := make (map [string ]* DenoProgramEntry , len (params .WorkspaceChange .NewConfiguration .ByNotebookUri ))
@@ -1153,7 +1158,9 @@ func (s *Server) handleDenoRequest(ctx context.Context, params *lsproto.DenoRequ
11531158 // Handle file changes by updating affected programs
11541159 for _ , fileChange := range params .WorkspaceChange .FileChanges {
11551160 // Clear document cache entry for changed file
1161+ s .deno .documentCacheMu .Lock ()
11561162 delete (s .deno .documentCache , fileChange .Uri )
1163+ s .deno .documentCacheMu .Unlock ()
11571164
11581165 filePath := tspath .ToPath (fileChange .Uri .FileName (), s .cwd , true )
11591166 updateProgram := func (pe * DenoProgramEntry ) {
0 commit comments