From 705272cba4001b8caf71a1542f376daa2e0be089 Mon Sep 17 00:00:00 2001 From: Rebecca Stambler Date: Thu, 7 Jan 2021 19:34:14 -0500 Subject: [PATCH] src/goLiveErrors: disable gotype-live when language server is enabled I decided that it was best not to warn the user about the setting because a lot of people may have it enabled, and we don't want to annoy them when we flip the default. Fixes golang/vscode-go#1021 Change-Id: I0cf75af4dbd7889f414042061c1b4b2c56e98311 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/282532 Trust: Rebecca Stambler Run-TryBot: Rebecca Stambler TryBot-Result: kokoro Reviewed-by: Hyang-Ah Hana Kim --- docs/settings.md | 2 +- package.json | 2 +- src/goLiveErrors.ts | 13 +++++++++---- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/docs/settings.md b/docs/settings.md index c52138627d..0490a63852 100644 --- a/docs/settings.md +++ b/docs/settings.md @@ -410,7 +410,7 @@ Default:{
The number of milliseconds to delay before execution. Resets with each keystroke. #### `enabled` -If true, runs gotype on the file currently being edited and reports any semantic or syntactic errors found. +If true, runs gotype on the file currently being edited and reports any semantic or syntactic errors found. Disabled when the language server is enabled. ### `go.logging.level` diff --git a/package.json b/package.json index e1a1188ccb..c2f324acd6 100644 --- a/package.json +++ b/package.json @@ -1778,7 +1778,7 @@ "enabled": { "type": "boolean", "default": false, - "description": "If true, runs gotype on the file currently being edited and reports any semantic or syntactic errors found." + "description": "If true, runs gotype on the file currently being edited and reports any semantic or syntactic errors found. Disabled when the language server is enabled." }, "delay": { "type": "number", diff --git a/src/goLiveErrors.ts b/src/goLiveErrors.ts index e6b6cb8220..fb592c580d 100644 --- a/src/goLiveErrors.ts +++ b/src/goLiveErrors.ts @@ -23,8 +23,13 @@ interface GoLiveErrorsConfig { let runner: NodeJS.Timer; export function goLiveErrorsEnabled() { - const goConfig = getGoConfig()['liveErrors']; - if (goConfig === null || goConfig === undefined || !goConfig.enabled) { + const goConfig = getGoConfig(); + // If the language server is enabled, there is no need for live errors. + if (goConfig['useLanguageServer'] === true) { + return false; + } + const liveErrorsConfig = goConfig['liveErrors']; + if (liveErrorsConfig === null || liveErrorsConfig === undefined || !liveErrorsConfig.enabled) { return false; } const files = vscode.workspace.getConfiguration('files', null); @@ -34,11 +39,11 @@ export function goLiveErrorsEnabled() { autoSave !== null && autoSave !== undefined && autoSave === 'afterDelay' && - autoSaveDelay < goConfig.delay * 1.5 + autoSaveDelay < liveErrorsConfig.delay * 1.5 ) { return false; } - return goConfig.enabled; + return liveErrorsConfig.enabled; } // parseLiveFile runs the gotype command in live mode to check for any syntactic or