lite-formatters icon indicating copy to clipboard operation
lite-formatters copied to clipboard

Formatting file breaks history (undo/redo)

Open panbroggi opened this issue 10 months ago • 3 comments

I am editing (mostly) julia files. I noticed that formatting a file with Alt+shift+R breaks the history of file modifications, accessible with undo/redo. This is particularily unpleasant when formatting an unsaved file, since it is not possible to recover the unsaved edits.

panbroggi avatar Apr 16 '24 13:04 panbroggi

Can you please send me a copy of the code you're trying to format?

PerilousBooklet avatar Apr 16 '24 19:04 PerilousBooklet

Here is a working example. If you create a file with this content:

a = 1+1
println( "Hello world!")

and save the file ctrl+s. Now press alt+shift+f, it will be formatted to

a = 1 + 1
println("Hello world!")

correctly. However, if you press ctrl+z the file won't revert to the previous stage. I noticed that if you don't save the file, you can revert.

panbroggi avatar Apr 16 '24 19:04 panbroggi

This is because the formatter formats the file in place, so it has to be saved to format, and when it's reloaded the history is lost. Perhaps I should fix this

vincens2005 avatar Apr 22 '24 16:04 vincens2005