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

Commit

Permalink
Allow disabling of docs in auto-completions #2152
Browse files Browse the repository at this point in the history
  • Loading branch information
ramya-rao-a committed Dec 14, 2018
1 parent 5783c95 commit e4522ba
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/goSuggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider,
private previousFile: string;
private previousFileDir: string;
private gocodeFlags: string[];
private excludeDocs: boolean = false;

constructor(globalState?: vscode.Memento) {
this.globalState = globalState;
Expand All @@ -82,7 +83,9 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider,
}

public resolveCompletionItem(item: vscode.CompletionItem, token: vscode.CancellationToken): vscode.ProviderResult<vscode.CompletionItem> {
if (!(item instanceof ExtendedCompletionItem) || item.kind === vscode.CompletionItemKind.Module) {
if (!(item instanceof ExtendedCompletionItem)
|| item.kind === vscode.CompletionItemKind.Module
|| this.excludeDocs) {
return;
}

Expand All @@ -101,6 +104,7 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider,
}

public provideCompletionItemsInternal(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken, config: vscode.WorkspaceConfiguration): Thenable<vscode.CompletionItem[] | vscode.CompletionList> {
this.excludeDocs = false;
this.gocodeFlags = ['-f=json'];
if (Array.isArray(config['gocodeFlags'])) {
this.gocodeFlags.push(...config['gocodeFlags']);
Expand Down Expand Up @@ -231,12 +235,19 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider,

// stamblerre/gocode does not support -unimported-packages flags.
if (this.isGoMod) {
const upflag = '-unimported-packages';
const idx = this.gocodeFlags.indexOf(upflag);
const idx = this.gocodeFlags.indexOf('-unimported-packages');
if (idx >= 0) {
this.gocodeFlags.splice(idx, 1);
}
}

// -exclude-docs is something we use internally and is not related to gocode
const idx = this.gocodeFlags.indexOf('-exclude-docs');
if (idx >= 0) {
this.gocodeFlags.splice(idx, 1);
this.excludeDocs = true;
}

// Spawn `gocode` process
let p = cp.spawn(gocode, [...this.gocodeFlags, 'autocomplete', filename, '' + offset], { env });
p.stdout.on('data', data => stdout += data);
Expand Down

0 comments on commit e4522ba

Please sign in to comment.