From 8ac965cea0cebe27c6fdf27d43a1e5bb6a07b872 Mon Sep 17 00:00:00 2001 From: filipw Date: Mon, 23 Nov 2020 14:36:26 +0100 Subject: [PATCH 1/2] only suppress file notifications for C# files --- src/features/changeForwarding.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/features/changeForwarding.ts b/src/features/changeForwarding.ts index 20c39d919..dc14752d1 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 { + let 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()) { From 5c63c428db701df2f19cec1033ee79acb5b6e632 Mon Sep 17 00:00:00 2001 From: filipw Date: Mon, 23 Nov 2020 20:07:02 +0100 Subject: [PATCH 2/2] let => const --- src/features/changeForwarding.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/changeForwarding.ts b/src/features/changeForwarding.ts index dc14752d1..0cc17a217 100644 --- a/src/features/changeForwarding.ts +++ b/src/features/changeForwarding.ts @@ -85,7 +85,7 @@ function forwardFileChanges(server: OmniSharpServer): IDisposable { } function isCSharpCodeFile(uri: Uri) : Boolean { - let normalized = uri.path.toLocaleLowerCase(); + const normalized = uri.path.toLocaleLowerCase(); return normalized.endsWith(".cs") || normalized.endsWith(".csx") || normalized.endsWith(".cake"); }