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

Close gocode daemon on deactivation #2137

Merged
merged 3 commits into from
Nov 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/goMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -561,5 +561,7 @@ function checkToolExists(tool: string) {
}

function registerCompletionProvider(ctx: vscode.ExtensionContext) {
ctx.subscriptions.push(vscode.languages.registerCompletionItemProvider(GO_MODE, new GoCompletionItemProvider(ctx.globalState), '.', '\"'));
let provider = new GoCompletionItemProvider(ctx.globalState);
ctx.subscriptions.push(provider);
ctx.subscriptions.push(vscode.languages.registerCompletionItemProvider(GO_MODE, provider, '.', '\"'));
}
11 changes: 9 additions & 2 deletions src/goSuggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ const lineCommentRegex = /^\s*\/\/\s+/;
const exportedMemberRegex = /(const|func|type|var)(\s+\(.*\))?\s+([A-Z]\w*)/;
const gocodeNoSupportForgbMsgKey = 'dontshowNoSupportForgb';

export class GoCompletionItemProvider implements vscode.CompletionItemProvider {

export class GoCompletionItemProvider implements vscode.CompletionItemProvider, vscode.Disposable {
private pkgsList = new Map<string, string>();
private killMsgShown: boolean = false;
private setGocodeOptions: boolean = true;
Expand Down Expand Up @@ -209,6 +208,14 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider {
});
}

public dispose() {
let gocodeName = this.isGoMod ? 'gocode-gomod' : 'gocode';
let gocode = getBinPath(gocodeName);
if (path.isAbsolute(gocode)) {
cp.spawn(gocode, ['close'], { env: getToolsEnvVars() });
}
}

private runGoCode(document: vscode.TextDocument, filename: string, inputText: string, offset: number, inString: boolean, position: vscode.Position, lineText: string, currentWord: string, includeUnimportedPkgs: boolean, config: vscode.WorkspaceConfiguration): Thenable<vscode.CompletionItem[]> {
return new Promise<vscode.CompletionItem[]>((resolve, reject) => {
let gocodeName = this.isGoMod ? 'gocode-gomod' : 'gocode';
Expand Down