diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-10-23 12:13:04 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-10-23 12:13:04 +0100 |
commit | d2e1f9f6da01132fd23394b5b789e4ef96ccc444 (patch) | |
tree | 686a96cbf68c7ae3c43c9f062d49cf70edd71cdb /editors/code/src/commands | |
parent | 195272270be99c353c9555c9e36c66068434af60 (diff) | |
parent | 770bb8dc9b0d2e693918a4f8c8039bf2c6deab66 (diff) |
Merge #1980
1980: Shorten inline type hints r=matklad a=detrumi
Implements #1946
Co-authored-by: Wilco Kusee <[email protected]>
Diffstat (limited to 'editors/code/src/commands')
-rw-r--r-- | editors/code/src/commands/inlay_hints.ts | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/editors/code/src/commands/inlay_hints.ts b/editors/code/src/commands/inlay_hints.ts index 5393a2bc9..ffaaaebcb 100644 --- a/editors/code/src/commands/inlay_hints.ts +++ b/editors/code/src/commands/inlay_hints.ts | |||
@@ -85,7 +85,11 @@ export class HintsUpdater { | |||
85 | if (newHints !== null) { | 85 | if (newHints !== null) { |
86 | const newDecorations = newHints.map(hint => ({ | 86 | const newDecorations = newHints.map(hint => ({ |
87 | range: hint.range, | 87 | range: hint.range, |
88 | renderOptions: { after: { contentText: `: ${hint.label}` } } | 88 | renderOptions: { |
89 | after: { | ||
90 | contentText: `: ${this.truncateHint(hint.label)}` | ||
91 | } | ||
92 | } | ||
89 | })); | 93 | })); |
90 | return editor.setDecorations( | 94 | return editor.setDecorations( |
91 | typeHintDecorationType, | 95 | typeHintDecorationType, |
@@ -94,6 +98,18 @@ export class HintsUpdater { | |||
94 | } | 98 | } |
95 | } | 99 | } |
96 | 100 | ||
101 | private truncateHint(label: string): string { | ||
102 | if (!Server.config.maxInlayHintLength) { | ||
103 | return label; | ||
104 | } | ||
105 | |||
106 | let newLabel = label.substring(0, Server.config.maxInlayHintLength); | ||
107 | if (label.length > Server.config.maxInlayHintLength) { | ||
108 | newLabel += '…'; | ||
109 | } | ||
110 | return newLabel; | ||
111 | } | ||
112 | |||
97 | private async queryHints(documentUri: string): Promise<InlayHint[] | null> { | 113 | private async queryHints(documentUri: string): Promise<InlayHint[] | null> { |
98 | const request: InlayHintsParams = { | 114 | const request: InlayHintsParams = { |
99 | textDocument: { uri: documentUri } | 115 | textDocument: { uri: documentUri } |