From e8b7003ee2e27c521402bfcf59d06e9c6c69b60f Mon Sep 17 00:00:00 2001 From: Gil Forsyth Date: Fri, 4 Mar 2016 10:15:49 -0500 Subject: [PATCH] fix collision with ptk multiline dedent and `pass` This is a bit of an edge case, but the password manager `pass` causes a few headaches with the multiline carriage return logic. Specifically, because `pass` is a `DEDENT_TOKEN` when running `pass` as the password manager the prompt will delete one indent-length's worth of characters on a `` press. This is a one-line fix to make sure that people can use `pass` in the PTK shell. Just running `pass` will be interpreted as a Pythonic `pass`, but commands like `pass git init` will work. If someone has a xsh script that uses `pass` it should be wrapped in `$[]`. --- xonsh/ptk/key_bindings.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/xonsh/ptk/key_bindings.py b/xonsh/ptk/key_bindings.py index d23b69be4..69a046c1b 100644 --- a/xonsh/ptk/key_bindings.py +++ b/xonsh/ptk/key_bindings.py @@ -36,7 +36,8 @@ def carriage_return(b, cli): b.insert_text(indent_, fire_event=False) # if current line isn't blank, check dedent tokens elif (not current_line_blank and - b.document.current_line.split(maxsplit=1)[0] in DEDENT_TOKENS): + b.document.current_line.split(maxsplit=1)[0] in DEDENT_TOKENS and + b.document.line_count > 1): b.newline(copy_margin=True) _ = b.delete_before_cursor(count=len(indent_)) elif (not b.document.on_first_line and