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

Format-on-save screws up undo/redo stack #678

Closed
@atombender

Description

For example, a simple Go file:

package main
func main() {}

Say I change main to foo and hit save. I'm using goimports to format; when save runs the formatter, nothing is changed because my code is already formatted correctly. However, VSCode-Go still seems to replace the entire document, which means that if I hit cmd-Z, nothing happens. I have to hit cmd-Z once more in order to undo my change.

VSCode-Go should realize that the newly formatted file is the same as the current file, and do nothing.

To be honest, I'd prefer if formatOnSave did not count as part of the undo stack. I'd prefer "save + undo" to undo the format and my last edit, which is a lot more rational; they do belong together, and I'd argue there's absolutely utility to undoing only the formatting but not your own edit. However, I don't know if VSCode offers the necessary plumbing to group undo operations like this. I noticed a very similar problem with the Autotrim extension.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions