Skip to content

Commit aa44ef7

Browse files
asmeurerjonathanslenders
authored andcommitted
Call accept_handler before append_to_history in Buffer.validate_and_handle
This was a regression from 6cfc3f3. Without this, any changes made to the buffer text in the accept handler are not reflected in the history. For instance, I call dedent(text).strip() in the accept handler.
1 parent d3d5579 commit aa44ef7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

prompt_toolkit/buffer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,13 +1613,13 @@ def validate_and_handle(self):
16131613

16141614
# When the validation succeeded, accept the input.
16151615
if valid:
1616-
self.append_to_history()
1617-
16181616
if self.accept_handler:
16191617
keep_text = self.accept_handler(self)
16201618
else:
16211619
keep_text = False
16221620

1621+
self.append_to_history()
1622+
16231623
if not keep_text:
16241624
self.reset()
16251625

0 commit comments

Comments
 (0)