diff --git a/src/goSuggest.ts b/src/goSuggest.ts index 80e761ad1..d06cd82a6 100644 --- a/src/goSuggest.ts +++ b/src/goSuggest.ts @@ -126,13 +126,20 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider, let suggestionItem: vscode.CompletionItem; if (memberType && memberType.length === 4) { 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) { - return resolve([]); + const commentPosition = new vscode.Position(position.line, commentIndex); + const isCommentInString = isPositionInString(document, commentPosition); + + if (!isCommentInString) { + return resolve([]); + } } let inString = isPositionInString(document, position);