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

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

Closed
klaidliadon opened this issue May 4, 2018 · 4 comments
Closed

Comments

@klaidliadon
Copy link

klaidliadon commented May 4, 2018

Right now go.useCodeSnippetsOnFunctionSuggestWithoutType: true always appends the snippet.

It would be really useful if it wouldn't when the first non-space character after the cursor is a (.

@ramya-rao-a
Copy link
Contributor

Can you give an example?

@klaidliadon
Copy link
Author

Suppose that | is the cursor and I have r.Lo|()
Since the round parenthesis are already there, when I choose Lock from the suggestions the line becomes r.Lock()() instead of r.Lock()

https://giphy.com/gifs/2yzHKEmXsaNQkyqrLv

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented May 8, 2018

Good point. Is this a very common occurrence only for functions with no parameters?

PRs are welcome to fix this.
The place to add the fix would be https://github.com/Microsoft/vscode-go/blob/0.6.79/src/goSuggest.ts#L171

@ramya-rao-a ramya-rao-a changed the title Feature: smart snippet function completition Avoid adding snippet for function suggest when cursor is followed by () May 8, 2018
lggomez added a commit to lggomez/vscode-go that referenced this issue May 29, 2018
Avoid adding snippet for function suggest when cursor is followed by (). Fixes microsoft#1655
ramya-rao-a pushed a commit that referenced this issue Jun 3, 2018
…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
@ramya-rao-a
Copy link
Contributor

This bug fix is now out in the latest update to the Go extension (0.6.81)

@ramya-rao-a ramya-rao-a added this to the 0.6.81 milestone Jun 4, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Jul 19, 2018
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Projects
None yet
Development

No branches or pull requests

2 participants