ahuth / brackets-paste-and-indent

Paste code at the correct indentation level
29 stars 7 forks source link

Undo history #1

Closed ahuth closed 10 years ago

ahuth commented 10 years ago

After pasting, the new lines get re-indented. This re-indentation step is added to the editor's undo history.

If you hit ctrl-z, or undo, after pasting something, it takes two undo's to actually undo the paste. The first un-does the indentation, and the second un-does the paste.

Not sure how to fix this because editing CodeMirror history is not something that its designed for. There are getHistory and setHistory methods on the CodeMirror doc object, but it's difficult to tell what history items are the indentation.

I've played around with getting the current history, removing the last 1 or two items from it, and resetting the history. This kind of works, but a lot of times results in chunks of the pasted code being left around after un-doing.

This might be because some of those undo events that get removed have to do with selection.

I'll keep working on this, but any help is also greatly appreciated.

To be clear: what we want is to not have the indenting step be in the undo history.

ahuth commented 10 years ago

Closing, because this isn't really important anymore.