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

Auto-complete fails in snippet completion #2474

Closed
tj opened this issue Apr 25, 2019 · 17 comments
Closed

Auto-complete fails in snippet completion #2474

tj opened this issue Apr 25, 2019 · 17 comments
Labels
upstream-gopls Issue for gopls

Comments

@tj
Copy link

tj commented Apr 25, 2019

I'm not sure if this is a VScode-level problem or something specific to Go / the language server but I think this used to work.

Screen Shot 2019-04-25 at 2 47 28 PM

Screen Shot 2019-04-25 at 2 47 37 PM

@tj tj changed the title Auto-complete fails in snippets Auto-complete fails in snippet completion Apr 25, 2019
@Hawken94
Copy link

Hawken94 commented Apr 26, 2019

#2469 this issue seems like your problem. And it has a temporary solution--revert the version of vscode-go

@tj
Copy link
Author

tj commented Apr 26, 2019

I think this is different, this only happens during a snippet's execution

@tj
Copy link
Author

tj commented Apr 27, 2019

Looks like it's not just snippets (manually typed defer in this case):

Screen Shot 2019-04-27 at 2 50 18 PM

Screen Shot 2019-04-27 at 2 50 23 PM

@imkos
Copy link

imkos commented Apr 28, 2019

0.9.2 is normal, 0.10.x has problems, and now auto-complete input lowercase will not match first.

@ramya-rao-a
Copy link
Contributor

Thanks for reporting @tj and @imkos

Can you share any Go related settings that you may have added/edited?

Also, please try the latest beta version of this extension which has the fix for #2469 and let me know how it makes any difference here.

@imkos
Copy link

imkos commented Apr 30, 2019

I tried this version (0.10.2-beta.1) and it seems that the recovery is as good as the 0.9.2 version.
When will the official revised version be available for download?

(node:4236) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.

@tj
Copy link
Author

tj commented Apr 30, 2019

@ramya-rao-a looks like it's still happening in the latest beta, and my tabSize seems to be stuck at 8 rather than 2 now. Here's all my settings at the moment:

{
    "window.zoomLevel": 0,
    "editor.tabSize": 2,
    "editor.minimap.enabled": false,
    "editor.folding": false,
    "editor.hover.delay": 150,
    "editor.renderIndentGuides": false,
    "editor.renderControlCharacters": false,
    "editor.renderLineHighlight": "none",
    "window.titleBarStyle": "custom",
    "telemetry.enableTelemetry": false,
    "go.addTags": {
        "tags": "json",
        "options": "",
        "promptForTags": false,
        "transform": "snakecase"
    },
    "go.gotoSymbol.includeGoroot": true,
    "emmet.showExpandedAbbreviation": "never",
    "go.testOnSave": false,
    "go.testTimeout": "15s",
    "editor.multiCursorModifier": "ctrlCmd",
    "editor.formatOnPaste": false,
    "editor.formatOnSave": false,
    "workbench.statusBar.visible": false,
    "workbench.activityBar.visible": false,
    "workbench.iconTheme": null,
    "workbench.colorTheme": "Supernova",
    "editor.scrollBeyondLastLine": false,
    "git.enableSmartCommit": true,
    "city-lights-icons-vsc.hidesExplorerArrows": false,
    "editor.find.seedSearchStringFromSelection": false,
    "editor.codeLens": false,
    "go.autocompleteUnimportedPackages": true,
    "explorer.confirmDragAndDrop": false,
    "editor.cursorBlinking": "solid",
    "workbench.startupEditor": "newUntitledFile",
    "emmet.showAbbreviationSuggestions": false,
    "go.useLanguageServer": true,
    "go.formatTool": "goreturns",
    "[go]": {
        "editor.formatOnSave": true,
        "editor.snippetSuggestions": "top",
        "editor.codeActionsOnSave": {
            "source.organizeImports": true
        }
    },
    "gopls": {
        "usePlaceholders": true, 
        "enhancedHover": true,
    },
    "atomKeymap.promptV3Features": true,
    "scm.diffDecorations": "none"
}

@ramya-rao-a
Copy link
Contributor

@tj The tab size should be back to normal in the beta update(0.10.2-beta.2) that I just released

Your settings look fine.

Can you share a small code sample where I can try and replicate your issue?

@tj
Copy link
Author

tj commented Apr 30, 2019

Sure! It may be a gopls issue, but if you have:

package main

import (
	"flag"
)

func main() {
	flag.Parse()
}

typing flag.P will show Parse, but typing defer flag.P gives me:

Screen Shot 2019-04-30 at 5 27 26 PM

I had the same results when using auto-complete in snippets but it looks like the same issue

@ramya-rao-a
Copy link
Contributor

@tj On second thoughts your issue is definitely different from #2469
#2469 is about the unimproved packages showing up in completions when they shouldn't
And your issue is about getting different completions for the same input but different locations

Please go to View -> Output. In the dropdown that appears on the top right corner of the panel, do you see gopls or go-langserver?

@tj
Copy link
Author

tj commented Apr 30, 2019

Looks like I have gopls there

@stamblerre
Copy link
Contributor

The defer issue is golang/go#29313. gopls autocompletion is still not perfect, and there are occasional cases where autocompletion does not work as expected. Please file any cases that you see here.

@tj
Copy link
Author

tj commented Apr 30, 2019

hmm ok interesting about defer.

I see the same behaviour with snippets, maybe that's the only VScode fault. For example typing for range flag.P is correct in showing Parse in my case, but if I have a for range $1 {} snippet and start to type flag.P it shows all that other built-in stuff.

@stamblerre
Copy link
Contributor

I think this is still a gopls issue with the range statement - particularly because looking at your original screenshot, it looks the like the range statement has an error (for _, := ). gopls occasionally will fail on broken code.

@tj
Copy link
Author

tj commented May 8, 2019

@stamblerre ahh that makes sense, my snippet goes to the right-hand side first and then left, but you're right, for that moment it's not valid Go, that's probably it I'll try tweaking the snippet

@tj
Copy link
Author

tj commented May 8, 2019

That did the trick, adjusting the snippet to have a placeholder is fine now. Closing this one, sorry for the noise!

@tj tj closed this as completed May 8, 2019
@stamblerre
Copy link
Contributor

Not noise at all! Filed golang/go#31907 so that we can ultimately handle more broken cases. Thank you!

@ramya-rao-a ramya-rao-a added upstream-gopls Issue for gopls and removed under-discussion labels May 9, 2019
@vscodebot vscodebot bot locked and limited conversation to collaborators Jun 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
upstream-gopls Issue for gopls
Projects
None yet
Development

No branches or pull requests

5 participants