From 260b78e026d5ff4591ee6f5b4ba0e0d97ae5de41 Mon Sep 17 00:00:00 2001 From: Karl Goffin Date: Sun, 20 Jan 2019 02:13:19 -0500 Subject: [PATCH] #2063 only suggest exported member name at start of comment (#2070) --- src/goSuggest.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/goSuggest.ts b/src/goSuggest.ts index 824e9cbcc..48da25e9d 100644 --- a/src/goSuggest.ts +++ b/src/goSuggest.ts @@ -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'; @@ -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) {