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 `<ENTER>` 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
`$[]`.
This commit is contained in:
Gil Forsyth 2016-03-04 10:15:49 -05:00
parent d3795eaeac
commit e8b7003ee2

View file

@ -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