Open bew opened 1 year ago
Hello!
While tweaking my ipython REPL keybindings, I discovered that buf.redo() never works.
buf.redo()
Here is a little script that shows the issue:
#!/usr/bin/env python from prompt_toolkit import PromptSession from prompt_toolkit.key_binding import KeyBindings def dyn_prompt(buf): def inner(): return f"undo: {len(buf._undo_stack)} | redo: {len(buf._redo_stack)}" return inner def main(): kb = KeyBindings() @kb.add("escape", "u") def _(event): event.current_buffer.undo() @kb.add("escape", "r") def _(event): event.current_buffer.redo() print("Try to type some text, then try: Alt-u to undo | Alt-r to redo") s = PromptSession("> ", key_bindings=kb) s.rprompt = dyn_prompt(s.app.current_buffer) try: s.prompt() except (EOFError, KeyboardInterrupt): pass if __name__ == "__main__": main()
abcdef
undo: 6 | redo: 0
Alt-u
f
undo: 5 | redo: 1
e
undo: 4 | redo: 1
Alt-r
undo: 5 | redo: 0
Is that the right way to try to use undo/redo ? Is that a bug on your side maybe?
I can confirm that behaviour. :-/
Hello!
While tweaking my ipython REPL keybindings, I discovered that
buf.redo()
never works.Here is a little script that shows the issue:
abcdef
undo: 6 | redo: 0
Alt-u
to undo (removef
)undo: 5 | redo: 1
Alt-u
to undo again (removee
)undo: 4 | redo: 1
(redo didn't change!)Alt-r
to try to redo (adde
)e
is not added, redo didn't work!undo: 5 | redo: 0
Is that the right way to try to use undo/redo ? Is that a bug on your side maybe?