Skip to content

Commit

Permalink
Merge pull request #4230 from filipw/bugfix/file-changed-events
Browse files Browse the repository at this point in the history
only suppress file changed notifications for C# files
  • Loading branch information
filipw authored Nov 27, 2020
2 parents 8f7b3d2 + 5c63c42 commit ed4c3ad
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/features/changeForwarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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;
}
}
Expand All @@ -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()) {
Expand Down

0 comments on commit ed4c3ad

Please sign in to comment.