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

Fix prevention of completion popup in line comments. (fixes #1659) #1671

Merged
merged 3 commits into from
May 13, 2018
Merged
Changes from 1 commit
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
5 changes: 3 additions & 2 deletions src/goSuggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider {
let lineTillCurrentPosition = lineText.substr(0, position.character);
let autocompleteUnimportedPackages = config['autocompleteUnimportedPackages'] === true && !lineText.match(/^(\s)*(import|package)(\s)+/);

if (lineText.match(/^\s*\/\//)) {
// prevent completion when typing in a line comment
const commentMatch = lineText.match(/\/\/.*$/);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just find the index directly using lineText.indexOf('//') ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.... That's a very good point. :)

if (commentMatch && position.character > commentMatch.index) {
return resolve([]);
}

Expand Down Expand Up @@ -327,4 +329,3 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider {
}
}
}