From 770bb8dc9b0d2e693918a4f8c8039bf2c6deab66 Mon Sep 17 00:00:00 2001 From: Wilco Kusee Date: Wed, 23 Oct 2019 13:11:40 +0200 Subject: Do not truncate the range --- editors/code/src/commands/inlay_hints.ts | 40 ++++++++------------------------ 1 file changed, 10 insertions(+), 30 deletions(-) (limited to 'editors') diff --git a/editors/code/src/commands/inlay_hints.ts b/editors/code/src/commands/inlay_hints.ts index 454a464d4..ffaaaebcb 100644 --- a/editors/code/src/commands/inlay_hints.ts +++ b/editors/code/src/commands/inlay_hints.ts @@ -83,20 +83,14 @@ export class HintsUpdater { ): Promise { const newHints = await this.queryHints(editor.document.uri.toString()); if (newHints !== null) { - const newDecorations = newHints.map(hint => { - const [label, range] = this.truncateHint( - hint.label, - hint.range - ); - return { - range, - renderOptions: { - after: { - contentText: `: ${label}` - } + const newDecorations = newHints.map(hint => ({ + range: hint.range, + renderOptions: { + after: { + contentText: `: ${this.truncateHint(hint.label)}` } - }; - }); + } + })); return editor.setDecorations( typeHintDecorationType, newDecorations @@ -104,30 +98,16 @@ export class HintsUpdater { } } - private truncateHint( - label: string, - range: vscode.Range - ): [string, vscode.Range] { + private truncateHint(label: string): string { if (!Server.config.maxInlayHintLength) { - return [label, range]; + return label; } let newLabel = label.substring(0, Server.config.maxInlayHintLength); if (label.length > Server.config.maxInlayHintLength) { newLabel += '…'; } - - range = new vscode.Range( - range.start.line, - range.start.character, - range.end.line, - Math.min( - range.start.character + Server.config.maxInlayHintLength, - range.end.character - ) - ); - - return [newLabel, range]; + return newLabel; } private async queryHints(documentUri: string): Promise { -- cgit v1.2.3