Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

only suppress file changed notifications for C# files #4230

Merged
merged 3 commits into from
Nov 27, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
333fred marked this conversation as resolved.
Show resolved Hide resolved
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