aboutsummaryrefslogtreecommitdiff
path: root/editors
diff options
context:
space:
mode:
authorWilco Kusee <[email protected]>2019-10-23 12:11:40 +0100
committerWilco Kusee <[email protected]>2019-10-23 12:11:40 +0100
commit770bb8dc9b0d2e693918a4f8c8039bf2c6deab66 (patch)
treec1a1dcf2b6902f689190ae1039c1b4a457cefa91 /editors
parent3b61acb4ae15a1ec6071db40e09437319795db67 (diff)
Do not truncate the range
Diffstat (limited to 'editors')
-rw-r--r--editors/code/src/commands/inlay_hints.ts40
1 files changed, 10 insertions, 30 deletions
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 {
83 ): Promise<void> { 83 ): Promise<void> {
84 const newHints = await this.queryHints(editor.document.uri.toString()); 84 const newHints = await this.queryHints(editor.document.uri.toString());
85 if (newHints !== null) { 85 if (newHints !== null) {
86 const newDecorations = newHints.map(hint => { 86 const newDecorations = newHints.map(hint => ({
87 const [label, range] = this.truncateHint( 87 range: hint.range,
88 hint.label, 88 renderOptions: {
89 hint.range 89 after: {
90 ); 90 contentText: `: ${this.truncateHint(hint.label)}`
91 return {
92 range,
93 renderOptions: {
94 after: {
95 contentText: `: ${label}`
96 }
97 } 91 }
98 }; 92 }
99 }); 93 }));
100 return editor.setDecorations( 94 return editor.setDecorations(
101 typeHintDecorationType, 95 typeHintDecorationType,
102 newDecorations 96 newDecorations
@@ -104,30 +98,16 @@ export class HintsUpdater {
104 } 98 }
105 } 99 }
106 100
107 private truncateHint( 101 private truncateHint(label: string): string {
108 label: string,
109 range: vscode.Range
110 ): [string, vscode.Range] {
111 if (!Server.config.maxInlayHintLength) { 102 if (!Server.config.maxInlayHintLength) {
112 return [label, range]; 103 return label;
113 } 104 }
114 105
115 let newLabel = label.substring(0, Server.config.maxInlayHintLength); 106 let newLabel = label.substring(0, Server.config.maxInlayHintLength);
116 if (label.length > Server.config.maxInlayHintLength) { 107 if (label.length > Server.config.maxInlayHintLength) {
117 newLabel += '…'; 108 newLabel += '…';
118 } 109 }
119 110 return newLabel;
120 range = new vscode.Range(
121 range.start.line,
122 range.start.character,
123 range.end.line,
124 Math.min(
125 range.start.character + Server.config.maxInlayHintLength,
126 range.end.character
127 )
128 );
129
130 return [newLabel, range];
131 } 111 }
132 112
133 private async queryHints(documentUri: string): Promise<InlayHint[] | null> { 113 private async queryHints(documentUri: string): Promise<InlayHint[] | null> {