diff --git a/src/features/changeForwarding.ts b/src/features/changeForwarding.ts index 20c39d919..0cc17a217 100644 --- a/src/features/changeForwarding.ts +++ b/src/features/changeForwarding.ts @@ -55,7 +55,7 @@ function forwardFileChanges(server: OmniSharpServer): IDisposable { } if (changeType === FileChangeType.Change) { - const docs = workspace.textDocuments.filter(doc => doc.uri.fsPath === uri.fsPath); + const docs = workspace.textDocuments.filter(doc => doc.uri.fsPath === uri.fsPath && isCSharpCodeFile(doc.uri)); if (Array.isArray(docs) && docs.some(doc => !doc.isClosed)) { // When a file changes on disk a FileSystemEvent is generated as well as a // DidChangeTextDocumentEvent.The ordering of these is: @@ -69,6 +69,8 @@ function forwardFileChanges(server: OmniSharpServer): IDisposable { // being that the file is now in an inconsistent state. // If the document is closed, however, it will no longer be synchronized, so the text change will // not be triggered and we should tell the server to reread from the disk. + // This applies to C# code files only, not other files significant for OmniSharp + // e.g. csproj or editorconfig files return; } } @@ -82,6 +84,11 @@ function forwardFileChanges(server: OmniSharpServer): IDisposable { }; } + function isCSharpCodeFile(uri: Uri) : Boolean { + const normalized = uri.path.toLocaleLowerCase(); + return normalized.endsWith(".cs") || normalized.endsWith(".csx") || normalized.endsWith(".cake"); + } + function onFolderEvent(changeType: FileChangeType): (uri: Uri) => void { return async function (uri: Uri) { if (!server.isRunning()) {