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 <rstambler@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
diff --git a/docs/settings.md b/docs/settings.md
index c521386..0490a63 100644
--- a/docs/settings.md
+++ b/docs/settings.md
@@ -410,7 +410,7 @@
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 e1a1188..c2f324a 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 e6b6cb8..fb592c5 100644
--- a/src/goLiveErrors.ts
+++ b/src/goLiveErrors.ts
@@ -23,8 +23,13 @@
let runner: NodeJS.Timer;
export function goLiveErrorsEnabled() {
- const goConfig = <GoLiveErrorsConfig>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 = <GoLiveErrorsConfig>goConfig['liveErrors'];
+ if (liveErrorsConfig === null || liveErrorsConfig === undefined || !liveErrorsConfig.enabled) {
return false;
}
const files = vscode.workspace.getConfiguration('files', null);
@@ -34,11 +39,11 @@
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