Set position at end when defaulting prompt

This commit is contained in:
Anthony Sottile
2020-01-08 22:20:01 -08:00
parent 1030f1170a
commit a36ea5d1ed
2 changed files with 12 additions and 3 deletions

View File

@@ -284,7 +284,7 @@ class Prompt:
self._prompt = prompt
self._lst = lst
self._y = len(lst) - 1
self._x = 0
self._x = len(self._s)
@property
def _s(self) -> str:

View File

@@ -107,7 +107,7 @@ def test_save_via_ctrl_o(run, tmpdir):
with run(str(f)) as h, and_exit(h):
h.press('hello world')
h.press('^O')
h.await_text(f'enter filename: {f}')
h.await_text(f'enter filename: ')
h.press('Enter')
h.await_text('saved! (1 line written)')
assert f.read() == 'hello world\n'
@@ -125,7 +125,7 @@ def test_save_via_ctrl_o_set_filename(run, tmpdir):
@pytest.mark.parametrize('key', ('^C', 'Enter'))
def test_save_via_ctrl_o_cancelled(run, tmpdir, key):
def test_save_via_ctrl_o_cancelled(run, key):
with run() as h, and_exit(h):
h.press('hello world')
h.press('^O')
@@ -134,6 +134,15 @@ def test_save_via_ctrl_o_cancelled(run, tmpdir, key):
h.await_text('cancelled')
def test_save_via_ctrl_o_position(run):
with run('filename') as h, and_exit(h):
h.press('hello world')
h.press('^O')
h.await_text('enter filename: filename')
h.await_cursor_position(x=24, y=23)
h.press('^C')
def test_save_on_exit_cancel_yn(run):
with run() as h, and_exit(h):
h.press('hello')