From 9d9e5fa5464bd4e15697730a567393a85bd84e7f Mon Sep 17 00:00:00 2001 From: Joey Robichaud Date: Mon, 2 Nov 2020 12:41:32 -0800 Subject: [PATCH] Do not call updateBuffer if there are no changes. --- src/features/changeForwarding.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/features/changeForwarding.ts b/src/features/changeForwarding.ts index db16747d6..03390e510 100644 --- a/src/features/changeForwarding.ts +++ b/src/features/changeForwarding.ts @@ -14,16 +14,21 @@ function forwardDocumentChanges(server: OmniSharpServer): IDisposable { return workspace.onDidChangeTextDocument(event => { - let { document } = event; + let { document, contentChanges } = event; if (document.isUntitled || document.languageId !== 'csharp' || document.uri.scheme !== 'file') { return; } + if (contentChanges.length === 0) { + // This callback fires with no changes when a document's state changes between "clean" and "dirty". + return; + } + if (!server.isRunning()) { return; } - const lineChanges = event.contentChanges.map(function (change): LinePositionSpanTextChange { + const lineChanges = contentChanges.map(function (change): LinePositionSpanTextChange { const range = change.range; return { NewText: change.text,