-
Notifications
You must be signed in to change notification settings - Fork 798
Unable to create a new line #3733
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi Thanks for reporting this issue, this is unexpected. But there might be a good explanation for this. I'm just guessing. Could you try using the configuration mentioned here. The go extension triggers a format on every save. Empty line is considered as mal-formatted code and will be cleaned up. From my editor the code below will be auto formatted once I hit ![]() to ![]() Did you configure |
Thanks a lot for your response. I set the formatOnSave to false, and that seemed to fix everything. I suspect the problem is that I have the VS code to autosave if there are no errors in my code; I don't manually save. So the formatOnSave was constantly formatting the code because my VScode autosaves whenever something in the file changes. Thanks a lot for your quick response! |
Of course. Glad it works. The same issue also reported recently by another user #3730. I will discuss within the Go team to see if this default behavior is too invasive and too hidden. See if we can make this more obvious by any means. I will mark this as closed. |
What version of Go, VS Code & VS Code Go extension are you using?
Version Information
go version
to get version of Go from the VS Code integrated terminal.gopls -v version
to get version of Gopls from the VS Code integrated terminal.code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders.Go: Locate Configured Go Tools
command.Tools Configuration
Environment
GOBIN: undefined
toolsGopath:
gopath: C:\Users\akash\go
GOROOT: C:\Program Files\Go
PATH: C:\Program Files\Go\bin;C:\Program Files\Eclipse Adoptium\jdk-21.0.4.7-hotspot\bin;C:\Program Files (x86)\Common Files\Oracle\Java\java8path;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Python312\Scripts;C:\Python312;C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit;C:\node.js;C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Node.js\Node.js.lnk;C:\TDM-GCC-64\bin;C:\Program Files\dotnet;C:\Program Files (x86)\Nodist\bin;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Program Files\MySQL\MySQL Shell 8.0\bin;C:\Users\akash.cargo\bin;C:\Users\akash\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\akash\flutter\bin;C:\Users\akash\AppData\Local\Android\Sdk\emulator;C:\node.js;C:\Users\akash\AppData\Local\GitHubDesktop\bin;C:\Users\akash\AppData\Local\Microsoft\WindowsApps;C:\Users\akash\AppData\Local\Programs\Swift\Runtimes\6.0.3\usr\bin;C:\Users\akash\AppData\Local\Programs\Swift\Toolchains\6.0.3+Asserts\usr\bin;C:\Users\akash\AppData\Local\Programs\Swift\Tools\6.0.3;C:\Users\akash\go\bin
PATH (vscode launched with): C:\Program Files\Eclipse Adoptium\jdk-21.0.4.7-hotspot\bin;C:\Program Files (x86)\Common Files\Oracle\Java\java8path;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Python312\Scripts;C:\Python312;C:\Program Files\Microsoft\jdk-11.0.16.101-hotspot\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit;C:\node.js;C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Node.js\Node.js.lnk;C:\TDM-GCC-64\bin;C:\Program Files\dotnet;C:\Program Files (x86)\Nodist\bin;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Program Files\Go\bin;C:\Program Files\MySQL\MySQL Shell 8.0\bin;C:\Users\akash.cargo\bin;C:\Users\akash\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\akash\flutter\bin;C:\Users\akash\AppData\Local\Android\Sdk\emulator;C:\node.js;C:\Users\akash\AppData\Local\GitHubDesktop\bin;C:\Users\akash\AppData\Local\Microsoft\WindowsApps;C:\Users\akash\AppData\Local\Programs\Swift\Runtimes\6.0.3\usr\bin;C:\Users\akash\AppData\Local\Programs\Swift\Toolchains\6.0.3+Asserts\usr\bin;C:\Users\akash\AppData\Local\Programs\Swift\Tools\6.0.3;C:\Users\akash\go\bin
Tools
Go env
Workspace Folder (Learn Go): c:\Learn Go
Share the Go related settings you have added/edited
Run
Preferences: Open Settings (JSON)
command to open your settings.json file.Share all the settings with the
go.
or["go"]
orgopls
prefixes."go.toolsManagement.autoUpdate": true,
Describe the bug
Every time I press enter to create a new line, I cannot create a new line without first declaring something on the current line. if I don't declare something and press Enter to go to the new line, I will be pushed back to the line I was already on. It only happens after I declare 'package main', if I don't include that then everything works as usual. This only happens when I have the GO extension installed, once I uninstall it everything works fine, I have also already tested uninstalling my other extensions while having the GO extension installed, and the same problems keep occurring. Only when I uninstall/disable the GO extension is the problem fixed.
Steps to reproduce the behavior:
1.create Go file, with GO extension installed
2.Declare package main
3. press 'Enter" to go to a new line
Screenshots or recordings
If applicable, add screenshots or recordings to help explain your problem.
20250325-0052-02.4816308.mp4
The text was updated successfully, but these errors were encountered: