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

Commit

Permalink
#2063 only suggest exported member name at start of comment (#2070)
Browse files Browse the repository at this point in the history
  • Loading branch information
kagof authored and ramya-rao-a committed Jan 20, 2019
1 parent 8c6f035 commit 260b78e
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/goSuggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class ExtendedCompletionItem extends vscode.CompletionItem {
fileName: string;
}

const lineCommentRegex = /^\s*\/\/\s+/;
const lineCommentFirstWordRegex = /^\s*\/\/\s+[\S]*$/;
const exportedMemberRegex = /(const|func|type|var)(\s+\(.*\))?\s+([A-Z]\w*)/;
const gocodeNoSupportForgbMsgKey = 'dontshowNoSupportForgb';

Expand Down Expand Up @@ -120,15 +120,15 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider,
let autocompleteUnimportedPackages = config['autocompleteUnimportedPackages'] === true && !lineText.match(/^(\s)*(import|package)(\s)+/);

// triggering completions in comments on exported members
if (lineCommentRegex.test(lineTillCurrentPosition) && position.line + 1 < document.lineCount) {
if (lineCommentFirstWordRegex.test(lineTillCurrentPosition) && position.line + 1 < document.lineCount) {
let nextLine = document.lineAt(position.line + 1).text.trim();
let memberType = nextLine.match(exportedMemberRegex);
let suggestionItem: vscode.CompletionItem;
if (memberType && memberType.length === 4) {
suggestionItem = new vscode.CompletionItem(memberType[3], vscodeKindFromGoCodeClass(memberType[1], ''));
suggestionItem = new vscode.CompletionItem(memberType[3], vscodeKindFromGoCodeClass(memberType[1], ''));
}
return resolve(suggestionItem ? [suggestionItem] : []);
}
return resolve(suggestionItem ? [suggestionItem] : []);
}
// prevent completion when typing in a line comment that doesnt start from the beginning of the line
const commentIndex = lineText.indexOf('//');
if (commentIndex >= 0 && position.character > commentIndex) {
Expand Down

0 comments on commit 260b78e

Please sign in to comment.