Implement save-on-exit

This commit is contained in:
Anthony Sottile
2019-12-21 23:12:37 -08:00
parent 98f19ca6b2
commit 7525e0bc84
4 changed files with 159 additions and 91 deletions

View File

@@ -44,6 +44,7 @@ def test_cut_uncut_multiple_file_buffers(tmpdir):
h.press('^K')
h.await_text_missing('hello')
h.press('^X')
h.press('n')
h.await_text_missing('world')
h.press('^U')
h.await_text('hello\ngood\nbye\n')

View File

@@ -133,3 +133,38 @@ def test_save_via_ctrl_o_cancelled(tmpdir, key):
h.await_text('enter filename:')
h.press(key)
h.await_text('cancelled')
def test_save_on_exit_cancel_yn():
with run() as h, and_exit(h):
h.press('hello')
h.await_text('hello')
h.press('^X')
h.await_text('file is modified - save [y(es), n(o)]?')
h.press('^C')
h.await_text('cancelled')
def test_save_on_exit_cancel_filename():
with run() as h, and_exit(h):
h.press('hello')
h.await_text('hello')
h.press('^X')
h.await_text('file is modified - save [y(es), n(o)]?')
h.press('y')
h.await_text('enter filename:')
h.press('^C')
h.await_text('cancelled')
def test_save_on_exit_save(tmpdir):
f = tmpdir.join('f')
with run(str(f)) as h:
h.press('hello')
h.await_text('hello')
h.press('^X')
h.await_text('file is modified - save [y(es), n(o)]?')
h.press('y')
h.await_text(f'enter filename: {f}')
h.press('Enter')
h.await_exit()