Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ Repository and `curl | sh` installs only; the PyPI package is unaffected.

**Fixed**

- Undo stepped back too far after a run of typing. A run was only ever
recorded as its first keystroke, so the undo point left behind held one
character of what had been typed: entering `KEEP`, pressing enter and
undoing once left `K`. The guard that was meant to keep the state in
sync while an action continued tested `current_state < len(history)-1`,
which is never true while editing forwards.
- Pasting indented text produced a staircase, each line indented further
than the last. A paste arrives as ordinary keystrokes, so auto indent
fired on every newline and prepended the previous line's whitespace to
Expand Down
14 changes: 9 additions & 5 deletions suplemon/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,15 @@ def store_action_state(self, action, state=None):
if self.last_action != action:
self.last_action = action
self.store_state(state)
else:
# FIXME: This if is here just for safety.
# FIXME: current_state might be wrong ;.<
if self.current_state < len(self.history)-1:
self.history[self.current_state].store(self)
elif self.current_state > 0:
# Same action continuing, so fold it into the state this run
# already created rather than making a new one. The guard used
# to be current_state < len(history)-1, which is never true
# while editing forwards: store_state leaves current_state at
# the end of the history. So a run was only ever recorded as
# its first keystroke, and the next different action left an
# undo point holding one character of what the user had typed.
self.history[self.current_state].store(self)

def store_state(self, state=None, action=None):
"""Store the current editor state for undo/redo."""
Expand Down
Loading