Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Avoid gopls crash due to -trace flag #2459
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Apr 24, 2019
1 parent 65ef2ea commit d0eed08
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ Below are the settings you can use to control the use of the language server. Yo

- Set `go.useLanguageServer` to `true` to enable the use of language server
- Use the setting `go.languageServerExperimentalFeatures` to control which features do you want to be powered by the language server.
- Set `"go.languageServerFlags": ["-logfile", "path to a text file that exists"]` to collect traces in a log file.
- Set `"go.languageServerFlags": ["-logfile", "path to a text file that exists"]` to collect logs in a log file.
- Set `"go.languageServerFlags": ["-rpc.trace"]` to see the complete rpc trace in the output panel (`View` -> `Output` -> `gopls`)

#### Setting to change the language server being used

Expand Down
6 changes: 6 additions & 0 deletions src/goMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ export function activate(ctx: vscode.ExtensionContext): void {
const languageServerExperimentalFeatures: any = vscode.workspace.getConfiguration('go').get('languageServerExperimentalFeatures') || {};
const langServerFlags: string[] = vscode.workspace.getConfiguration('go')['languageServerFlags'] || [];

// `-trace was a flag for `go-langserver` which is replaced with `-rpc.trace` for gopls to avoid crash
const traceFlagIndex = langServerFlags.indexOf('-trace');
if (traceFlagIndex > -1 && languageServerTool === 'gopls') {
langServerFlags[traceFlagIndex] = '-rpc.trace';
}

const c = new LanguageClient(
languageServerTool,
{
Expand Down

0 comments on commit d0eed08

Please sign in to comment.