about summary refs log tree commit diff
path: root/editors/code/src
diff options
context:
space:
mode:
authorDJMcNab <36049421+DJMcNab@users.noreply.github.com>2018-12-24 13:43:08 +0000
committerDJMcNab <36049421+DJMcNab@users.noreply.github.com>2018-12-24 13:43:08 +0000
commitecab036d6ffcb85c45a288b312d79141bcd86fd9 (patch)
tree176751d4b3dadf6ce15af1890c1d6ae49986936c /editors/code/src
parenta0e8538129131b5c7cb770f5e07f9723b4194ca6 (diff)
downloadrust-ecab036d6ffcb85c45a288b312d79141bcd86fd9.tar.gz
rust-ecab036d6ffcb85c45a288b312d79141bcd86fd9.zip
Add a very hacky workaround to not trace decorations requests
Diffstat (limited to 'editors/code/src')
-rw-r--r--editors/code/src/server.ts26
1 files changed, 25 insertions, 1 deletions
diff --git a/editors/code/src/server.ts b/editors/code/src/server.ts
index 75e273f3739..75bdf320708 100644
--- a/editors/code/src/server.ts
+++ b/editors/code/src/server.ts
@@ -22,7 +22,7 @@ export class Server {
         const clientOptions: lc.LanguageClientOptions = {
             documentSelector: [{ scheme: 'file', language: 'rust' }],
             initializationOptions: {
-                publishDecorations: true,
+                publishDecorations: true
             }
         };
 
@@ -32,6 +32,30 @@ export class Server {
             serverOptions,
             clientOptions
         );
+        // HACK: This is an awful way of filtering out the decorations notifications
+        // However, pending proper support, this is the most effecitve approach
+        // Proper support for this would entail a change to vscode-languageclient to allow not notifying on certain messages
+        // Or the ability to disable the serverside component of highlighting (but this means that to do tracing we need to disable hihlighting)
+        // This also requires considering our settings strategy, which is work which needs doing
+        // @ts-ignore The tracer is private to vscode-languageclient, but we need access to it to not log publishDecorations requests
+        Server.client._tracer = {
+            log: (messageOrDataObject: string | any, data?: string) => {
+                if (typeof messageOrDataObject === 'string') {
+                    if (
+                        messageOrDataObject.includes('m/publishDecorations') ||
+                        messageOrDataObject.includes('m/decorationsRequest')
+                    ) {
+                        // Don't log publish decorations requests
+                    } else {
+                        // @ts-ignore This is just a utility function
+                        Server.client.logTrace(messageOrDataObject, data);
+                    }
+                } else {
+                    // @ts-ignore
+                    Server.client.logObjectTrace(messageOrDataObject);
+                }
+            }
+        };
         Server.client.onReady().then(() => {
             for (const [type, handler] of notificationHandlers) {
                 Server.client.onNotification(type, handler);