mirror of
https://github.com/usestrix/strix.git
synced 2026-10-05 02:41:38 +00:00
fix(resume-picker): cancel on ctrl+c during drawing too
This commit is contained in:
parent
28fa7f7734
commit
aa3144dac4
2 changed files with 17 additions and 5 deletions
|
|
@ -380,14 +380,12 @@ class ResumePicker:
|
|||
try:
|
||||
self.draw()
|
||||
while True:
|
||||
try:
|
||||
key = next_key()
|
||||
except KeyboardInterrupt:
|
||||
key = KEY_INTERRUPT
|
||||
done, chosen = self.handle(key)
|
||||
done, chosen = self.handle(next_key())
|
||||
if done:
|
||||
return chosen
|
||||
self.draw()
|
||||
except KeyboardInterrupt:
|
||||
return None
|
||||
finally:
|
||||
self.clear()
|
||||
self.console.file.write(_CURSOR_SHOW)
|
||||
|
|
|
|||
|
|
@ -230,6 +230,20 @@ def test_sigint_while_waiting_for_a_key_cancels_and_restores_the_cursor() -> Non
|
|||
assert buffer.getvalue().endswith("\x1b[?25h")
|
||||
|
||||
|
||||
def test_sigint_while_drawing_cancels_and_restores_the_cursor() -> None:
|
||||
console, buffer = _console()
|
||||
picker = ResumePicker(RUNS, console=console, runs_dir="strix_runs", now=NOW)
|
||||
draw = picker.draw
|
||||
|
||||
def interrupted_draw() -> None:
|
||||
draw()
|
||||
raise KeyboardInterrupt
|
||||
|
||||
picker.draw = interrupted_draw # type: ignore[method-assign]
|
||||
assert picker.run(lambda: KEY_DOWN) is None
|
||||
assert buffer.getvalue().endswith("\x1b[?25h")
|
||||
|
||||
|
||||
def test_pick_run_needs_a_terminal() -> None:
|
||||
console, _ = _console()
|
||||
with pytest.raises(PickerUnavailableError):
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue