GoLand Repositions Caret Upon Desktop Switch

Completed

I am working with GoLand on macOS. I use multiple (virtual) desktops on my MacBook and switch back and forth between them. Oftentimes, when I switch away from the desktop where GoLand resides and then come back to it, the caret has changed position. Take the following example:

Where I leave the caret:

type index struct {
file *os.File
mmap gommap.MMap
<caret here>
}

Where it is when I come back:

type index struct {
file *os.File
mmap gommap.MMap
<caret here now>}

In this example, my still-empty newline was removed and the caret that was positioned there was positioned elsewhere.

This automatic reformatting and caret repositioning is extremely distracting and interrupts my flow. Is it a bug or a feature? In case of the latter, how can I disable it?

Thank you so much in advance!

0
2 comments
Official comment

Hello,

The feature is called Actions on Save. It executes Reformat Code action with gofmt on save by default.

There are a few ways to avoid changing the caret position:

  • Disable Save files when switching to a different application or a built-in terminal via Preferences | Appearance & Behavior | System Settings.
  • Disable Reformat Code on save completely via Preferences | Tools | Actions on Save.

I hope it helps.

Works perfectly, thank you! :)

1

Please sign in to leave a comment.