Remove unnecessary hacks

This commit is contained in:
Kirill Bulatov 2019-07-24 23:30:18 +03:00
parent 583f5c9612
commit bd904247ba

View file

@ -2,7 +2,6 @@ import * as vscode from 'vscode';
import {
Range,
TextDocumentChangeEvent,
TextDocumentContentChangeEvent,
TextEditor
} from 'vscode';
import { TextDocumentIdentifier } from 'vscode-languageclient';
@ -66,40 +65,12 @@ export class HintsUpdater {
return;
}
// If the dbg! macro is used in the lsp-server, an endless stream of events with `cause.contentChanges` with the dbg messages.
// Should not be a real situation, but better to filter such things out.
if (
cause !== undefined &&
cause.contentChanges.filter(changeEvent =>
this.isEventInFile(document.lineCount, changeEvent)
).length === 0
) {
return;
}
return await this.updateDecorationsFromServer(
document.uri.toString(),
editor
);
}
private isEventInFile(
documentLineCount: number,
event: TextDocumentContentChangeEvent
): boolean {
const eventText = event.text;
if (eventText.length === 0) {
return (
event.range.start.line <= documentLineCount ||
event.range.end.line <= documentLineCount
);
} else {
return (
event.range.start.line <= documentLineCount &&
event.range.end.line <= documentLineCount
);
}
}
private async updateDecorationsFromServer(
documentUri: string,
editor: TextEditor