rust-lang / rust-lang/rust-mode

Formatting breaks undo, sometimes

Open
#329 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

rustfmt
Dominant language
Emacs Lisp
Stars
1.3k
Forks
198
PR merge metrics
No merged PRs in 30d

Description

Hi, I'm surprised this hasn't been reported before, so maybe this is a misconfiguration... but is it possible that formatting breaks undo? I have rust-format-on-save enabled and quite often, after saving, either undo does nothing or I get a message saying that the end of undo history has been reached, when clearly there were previous edits. I haven't figured out a pattern yet, but this only appears to happen sometimes.

Obviously, undo can't work in the newly formatted buffer (by which I mean, an edit can't be undone while preserving the new format) but it should be possible to undo the formatting itself (and then any previous edits); this is, for example, how prettier-emacs works.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the problem with rust-format-on-save enabled and compare undo behavior before and after saving. The issue provides no file or test entry point; done means formatting can itself be undone and earlier edits remain available afterward.

Written by the indexing model from the issue text.

Assessment

Tech stack
emacs-lisp, rust
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.