Skip to content

Commit ed4c3ad

Browse files
authored
Merge pull request #4230 from filipw/bugfix/file-changed-events
only suppress file changed notifications for C# files
2 parents 8f7b3d2 + 5c63c42 commit ed4c3ad

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/features/changeForwarding.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function forwardFileChanges(server: OmniSharpServer): IDisposable {
5555
}
5656

5757
if (changeType === FileChangeType.Change) {
58-
const docs = workspace.textDocuments.filter(doc => doc.uri.fsPath === uri.fsPath);
58+
const docs = workspace.textDocuments.filter(doc => doc.uri.fsPath === uri.fsPath && isCSharpCodeFile(doc.uri));
5959
if (Array.isArray(docs) && docs.some(doc => !doc.isClosed)) {
6060
// When a file changes on disk a FileSystemEvent is generated as well as a
6161
// DidChangeTextDocumentEvent.The ordering of these is:
@@ -69,6 +69,8 @@ function forwardFileChanges(server: OmniSharpServer): IDisposable {
6969
// being that the file is now in an inconsistent state.
7070
// If the document is closed, however, it will no longer be synchronized, so the text change will
7171
// not be triggered and we should tell the server to reread from the disk.
72+
// This applies to C# code files only, not other files significant for OmniSharp
73+
// e.g. csproj or editorconfig files
7274
return;
7375
}
7476
}
@@ -82,6 +84,11 @@ function forwardFileChanges(server: OmniSharpServer): IDisposable {
8284
};
8385
}
8486

87+
function isCSharpCodeFile(uri: Uri) : Boolean {
88+
const normalized = uri.path.toLocaleLowerCase();
89+
return normalized.endsWith(".cs") || normalized.endsWith(".csx") || normalized.endsWith(".cake");
90+
}
91+
8592
function onFolderEvent(changeType: FileChangeType): (uri: Uri) => void {
8693
return async function (uri: Uri) {
8794
if (!server.isRunning()) {

0 commit comments

Comments
 (0)