Move type inlay hint truncation to language server

This commit implements a general truncation framework for HirFormatter
that keeps track of how much has been output so far. This information
can then be used to perform truncation inside the language server,
instead of relying on the client.

Initial support is implemented for truncating types hints using the
maxInlayHintLength server config option. The existing solution in the
VSCode extension has been removed in favor of letting the server
truncate type hints.
This commit is contained in:
Emil Lauridsen 2019-11-18 18:02:28 +01:00
parent c24ee09904
commit dadad36bb9
10 changed files with 97 additions and 35 deletions

View file

@ -87,7 +87,7 @@ export class HintsUpdater {
range: hint.range,
renderOptions: {
after: {
contentText: `: ${this.truncateHint(hint.label)}`
contentText: `: ${hint.label}`
}
}
}));
@ -98,18 +98,6 @@ export class HintsUpdater {
}
}
private truncateHint(label: string): string {
if (!Server.config.maxInlayHintLength) {
return label;
}
let newLabel = label.substring(0, Server.config.maxInlayHintLength);
if (label.length > Server.config.maxInlayHintLength) {
newLabel += '…';
}
return newLabel;
}
private async queryHints(documentUri: string): Promise<InlayHint[] | null> {
const request: InlayHintsParams = {
textDocument: { uri: documentUri }