about summary refs log tree commit diff
path: root/editors/code/src
diff options
context:
space:
mode:
authorEmil Lauridsen <mine809@gmail.com>2019-11-18 18:02:28 +0100
committerEmil Lauridsen <mine809@gmail.com>2019-11-19 17:23:50 +0100
commitdadad36bb9770f9b13ed84bc219ea0168a7a5bf1 (patch)
tree00051540da204b4294501f3c56960975177ae502 /editors/code/src
parentc24ee0990486b04723534f072d7a58e829bbd1bd (diff)
downloadrust-dadad36bb9770f9b13ed84bc219ea0168a7a5bf1.tar.gz
rust-dadad36bb9770f9b13ed84bc219ea0168a7a5bf1.zip
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.
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/commands/inlay_hints.ts14
-rw-r--r--editors/code/src/server.ts1
2 files changed, 2 insertions, 13 deletions
diff --git a/editors/code/src/commands/inlay_hints.ts b/editors/code/src/commands/inlay_hints.ts
index ffaaaebcb05..0dbdd94fbac 100644
--- a/editors/code/src/commands/inlay_hints.ts
+++ b/editors/code/src/commands/inlay_hints.ts
@@ -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 }
diff --git a/editors/code/src/server.ts b/editors/code/src/server.ts
index a3ef21a1671..7907b70bc51 100644
--- a/editors/code/src/server.ts
+++ b/editors/code/src/server.ts
@@ -43,6 +43,7 @@ export class Server {
             initializationOptions: {
                 publishDecorations: true,
                 lruCapacity: Server.config.lruCapacity,
+                maxInlayHintLength: Server.config.maxInlayHintLength,
                 excludeGlobs: Server.config.excludeGlobs,
                 useClientWatching: Server.config.useClientWatching,
                 featureFlags: Server.config.featureFlags