Skip to content

Commit

Permalink
src/goLiveErrors: disable gotype-live when language server is enabled
Browse files Browse the repository at this point in the history
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 #1021

Change-Id: I0cf75af4dbd7889f414042061c1b4b2c56e98311
Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/282532
Trust: Rebecca Stambler <[email protected]>
Run-TryBot: Rebecca Stambler <[email protected]>
TryBot-Result: kokoro <[email protected]>
Reviewed-by: Hyang-Ah Hana Kim <[email protected]>
  • Loading branch information
stamblerre committed Jan 8, 2021
1 parent ae693b8 commit 705272c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ Default:{<br/>
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`

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 9 additions & 4 deletions src/goLiveErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@ interface GoLiveErrorsConfig {
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);
Expand All @@ -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
Expand Down

0 comments on commit 705272c

Please sign in to comment.