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

Commit

Permalink
Avoid duplicate function parameter body on function suggest snippets (#…
Browse files Browse the repository at this point in the history
…1696)

* Avoid duplicate function parameter body on function suggest snippets

Avoid adding snippet for function suggest when cursor is followed by (). Fixes #1655

* Review feedback. Simplify logic

* Review feedback. Simplify logic
  • Loading branch information
lggomez authored and ramya-rao-a committed Jun 3, 2018
1 parent eb1c86d commit 10acfbd
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/goSuggest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,11 @@ export class GoCompletionItemProvider implements vscode.CompletionItemProvider {
paramSnippets.push('${' + (i + 1) + ':' + param + '}');
}
}
item.insertText = new vscode.SnippetString(suggest.name + '(' + paramSnippets.join(', ') + ')');
// Avoid adding snippet for function suggest when cursor is followed by ()
// i.e: met() -> method()()
if (lineText.substr(position.character, 2) !== '()') {
item.insertText = new vscode.SnippetString(suggest.name + '(' + paramSnippets.join(', ') + ')');
}
}
if (config['useCodeSnippetsOnFunctionSuggest'] && suggest.class === 'type' && suggest.type.startsWith('func(')) {
let { params, returnType } = getParametersAndReturnType(suggest.type.substring(4));
Expand Down

0 comments on commit 10acfbd

Please sign in to comment.