mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-14 02:49:40 +00:00
Remove unnecessary hacks
This commit is contained in:
parent
583f5c9612
commit
bd904247ba
@ -2,7 +2,6 @@ import * as vscode from 'vscode';
|
|||||||
import {
|
import {
|
||||||
Range,
|
Range,
|
||||||
TextDocumentChangeEvent,
|
TextDocumentChangeEvent,
|
||||||
TextDocumentContentChangeEvent,
|
|
||||||
TextEditor
|
TextEditor
|
||||||
} from 'vscode';
|
} from 'vscode';
|
||||||
import { TextDocumentIdentifier } from 'vscode-languageclient';
|
import { TextDocumentIdentifier } from 'vscode-languageclient';
|
||||||
@ -66,40 +65,12 @@ export class HintsUpdater {
|
|||||||
return;
|
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(
|
return await this.updateDecorationsFromServer(
|
||||||
document.uri.toString(),
|
document.uri.toString(),
|
||||||
editor
|
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(
|
private async updateDecorationsFromServer(
|
||||||
documentUri: string,
|
documentUri: string,
|
||||||
editor: TextEditor
|
editor: TextEditor
|
||||||
|
Loading…
Reference in New Issue
Block a user