only update in-memory file text from external change if open
This commit is contained in:
@@ -34,6 +34,14 @@ public class IdeOpenTabsFileManager(ILogger<IdeOpenTabsFileManager> logger)
|
||||
_openFiles[file] = newLazyTask;
|
||||
}
|
||||
|
||||
public async Task UpdateFileTextInMemoryIfOpen(SharpIdeFile file, string newText)
|
||||
{
|
||||
if (!_openFiles.ContainsKey(file)) return;
|
||||
|
||||
var newLazyTask = new Lazy<Task<string>>(() => Task.FromResult(newText));
|
||||
_openFiles[file] = newLazyTask;
|
||||
}
|
||||
|
||||
public async Task SaveFileAsync(SharpIdeFile file)
|
||||
{
|
||||
if (!_openFiles.ContainsKey(file)) throw new InvalidOperationException("File is not open in memory.");
|
||||
|
||||
@@ -68,7 +68,7 @@ public class FileChangedService(RoslynAnalysis roslynAnalysis, IdeOpenTabsFileMa
|
||||
// Disk is already up to date
|
||||
// Update any open tabs
|
||||
// update in memory
|
||||
await _openTabsFileManager.UpdateFileTextInMemory(file, newContents);
|
||||
await _openTabsFileManager.UpdateFileTextInMemoryIfOpen(file, newContents);
|
||||
file.FileContentsChangedExternally.InvokeParallelFireAndForget(linePosition);
|
||||
}
|
||||
else if (changeType is FileChangeType.CodeActionChange)
|
||||
|
||||
Reference in New Issue
Block a user