GoLand Repositions Caret Upon Desktop Switch

已完成

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!

评论操作 固定链接
正式评论

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

请先登录再写评论。