Merge pull request #645 from gforsyth/windows_multiline

disable multiline for '\' on windows without POSIX
This commit is contained in:
Morten Enemark Lund 2016-01-23 06:44:46 +01:00
commit 8b8696385f
2 changed files with 14 additions and 5 deletions

View file

@ -8,6 +8,7 @@ from prompt_toolkit.interface import CommandLineInterface
from prompt_toolkit.document import Document
from prompt_toolkit.buffer import Buffer, AcceptAction
from xonsh.environ import Env
from xonsh.tools import ON_WINDOWS
def setup():
global indent_
@ -69,10 +70,15 @@ def test_continuation_line():
assert_equal(buffer.document.current_line, '')
def test_trailing_slash():
document = Document('this line will \\')
buffer.set_document(document)
carriage_return(buffer, cli)
assert_equal(buffer.document.current_line, '')
mock = MagicMock(return_value = True)
with patch('xonsh.ptk.key_bindings.can_compile', mock):
document = Document('this line will \\')
buffer.set_document(document)
carriage_return(buffer, cli)
if not ON_WINDOWS:
assert_equal(buffer.document.current_line, '')
else:
assert bufaccept.mock_calls is not None
def test_cant_compile_newline():
mock = MagicMock(return_value = False)

View file

@ -4,6 +4,7 @@ import builtins
from prompt_toolkit.filters import Filter, IsMultiline
from prompt_toolkit.keys import Keys
from xonsh.tools import ON_WINDOWS
env = builtins.__xonsh_env__
indent_ = env.get('INDENT')
@ -41,7 +42,9 @@ def carriage_return(b, cli):
elif (not b.document.on_first_line and
not current_line_blank):
b.newline(copy_margin=True)
elif b.document.char_before_cursor == '\\':
elif (b.document.char_before_cursor == '\\' and
not (not builtins.__xonsh_env__.get('FORCE_POSIX_PATHS')
and ON_WINDOWS)):
b.newline()
elif (b.document.find_next_word_beginning() is not None and
(any(not _is_blank(i)