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,