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

package main completion issue #225

Closed
freeformz opened this issue Mar 4, 2016 · 7 comments
Closed

package main completion issue #225

freeformz opened this issue Mar 4, 2016 · 7 comments

Comments

@freeformz
Copy link

Main a new file, start typing "package main" + Enter and you get this:

sadmain

@lukehoban
Copy link
Contributor

Do you have the latest version of the extension installed? There was a fix yesterday which should have made this less likely to happen.

@freeformz
Copy link
Author

I updated to the latest released version, restarted vscode and the same thing happens.

@lukehoban
Copy link
Contributor

Yeah - the issue is the main snippet - which is handy when you want to use it, but can get in the way when you don't. Not sure what to do about that without removing the snippet.

The one thing that did change recently is that you should get a completion suggestion as you start typing package which will offer to complete package main\n for you. If you select that before you get to typing the main part, it will autocomplete what you want.

But that doesn't fully solve the issue.

I think the options are:

  • Leave this behaviour as is.
  • Remove all snippets.
  • Rename the main snippet to something less likely to interfere with normal typing (like im and ims which are used for imports).

I don't love any of the options though.

@freeformz
Copy link
Author

I find the existing auto-completion/snippet for package to be off. It suggests the name (seemingly anyway) based on the directory you are in. IMO it should look at other files in the same directory and default to the same package, unless it's a _test.go file where it could look at other test files in the same directory and default to the same package name. For what I do anyway, if there are no other go files it should default to package main. But maybe I'm off and my work flow isn't the same as other people's?

@freeformz
Copy link
Author

Is there any way to squash the auto-complete if the line starts with package? This way when I type package main I never get the main function auto-complete?

@wolfie82
Copy link

wolfie82 commented Apr 9, 2016

This is a problem in the atom editor as well. It would be nice if we could stop the evaluation of the snippet.

You could also:

  • Remove main as a snippet prefix
  • Create snippet prefix pkgm that will create both the package main designation and the main function

@lukehoban
Copy link
Contributor

@patbaker82 I like that suggestion - it replaces the main snippet with something more useful when you want to create a main file, plus avoids the name clash.

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants