Keep state of collapsed block when save


GoLand Version: 2022.3.2(223.8617.44) with New UI enabled

I recently restore my m1 mac to factory setting, and update to the latest GoLand. When I experiencing the latest GoLand I found a small but annoying issue: GoLand keeps unfold my code when I save files(I enable action on save).

For example:

When I hit Command+Control+"-", current file's code will all fold like below

var a = 1

function testFold() {...}

function testFold2() {...}

But if I change the code, and hit Command+S to save(or Control+S, I counldn't remember the correct name, only the shortcut), some of the folded blocks will automatically unfold.

That's annoying when I focusing on specify lines, made a change, save it  and suddenly those unfold block will cause my focused line's position to change and I have to scroll to it, find the lines, re-focusing.


How to disable this behavior? When I use older version, this behavior never exist, couldn't remember which old version I was previously using.


When I hit Command+Control+"-", current file's code will all fold like below

Sorry I mean Command+Shift+ "-", or Control+Shift+"-"


More testing gives me these behavior:

  1. In a small file which contains only 30~ lines, this behavior not exist
  2. In a medium file which contains 150~ lines, this behavior looks like this: press save shortcut -> unfold some folded block, then fold it back, it's human noticeable.
  3. In a large file which contains 220~ lines, this behavior looks like this: press save shortcun -> unfold some folder block, then fold some of them back, leaving others unfolded.

I'm running GoLand on M1 MackbookPro so performance is not a issue(only 15% cpu load and 70% memory load)



It seems that adding a file watcher of gofmt solve the issue, but I don't get it, What does file watcher do? I already had "run gofmt on code format" in "Code Style" and enable the `Reformat code on save` in "Tool->Action on save", didn't that using gofmt already? Why adding a file watcher of already in-use gofmt solve the problem...



May I ask you to upload a screencast with incorrect behavior to and provide the ID?


I'm seeing this too. If you can't reproduce, please ask your co-workers. As a paying customer, I shouldn't replace your own QA.

GoLand 2022.3.4
Build #GO-223.8836.56, built on March 22, 2023
Licensed to ken
Subscription is active until September 1, 2023.
Runtime version: 17.0.6+1-b653.34 x86_64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
macOS 12.6.3
GC: G1 Young Generation, G1 Old Generation
Memory: 2048M
Cores: 16
Metal Rendering is ON

Non-Bundled Plugins:
    com.jetbrains.gerryCyberpunk (2023.1.10) (5.7.4)
    dev.meanmail.plugin.nginx-intellij-plugin (2022.1.1)
    com.arcticicestudio.nord.jetbrains (0.13.0)
    com.jetbrains.gerryPurpleTheme (2023.1.30)
    org.intellij.plugins.hcl (223.8214.6)
    com.thvardhan.gradianto (5.1)
    org.toml.lang (223.8214.6)
    zielu.gittoolbox (500.0.5+213)
    ru.adelf.idea.dotenv (2022.3)


Guys, may I ask you to try out 2023.1 version of GoLand? It seems that the problem cannot be reproduced anymore.


It's still happen in my case. using GoLand Build #GO-231.9011.34, built on May 16, 2023 -- on Macbook M1 Pro.
Quite annoying, when editing quite large codebase (and 1 file contains more than 500 lines of code).
When folding certain method, and doing editing on the same file (e.g. adding space) and then save, the folded method get unfolded, and my focus scattered due to I have to find/scroll again to locate where the line I'm editing.


I have the same issue as well, and i am on Goland 2023-2.3

Build #GO-232.10072.27, built on October 11, 2023

Runtime version: amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.


Please sign in to leave a comment.