Merge pull request #113 from asottile/case_insensitive_short_answers
ignore case for quick prompt answers
This commit is contained in:
@@ -273,7 +273,7 @@ class Screen:
|
||||
prompt: str,
|
||||
opt_strs: Tuple[str, ...],
|
||||
) -> Union[str, PromptResult]:
|
||||
opts = [opt[0] for opt in opt_strs]
|
||||
opts = {opt[0] for opt in opt_strs}
|
||||
while True:
|
||||
x = 0
|
||||
prompt_line = self.margin.lines - 1
|
||||
@@ -310,8 +310,8 @@ class Screen:
|
||||
self.resize()
|
||||
elif key.keyname == b'^C':
|
||||
return self.status.cancelled()
|
||||
elif isinstance(key.wch, str) and key.wch in opts:
|
||||
return key.wch
|
||||
elif isinstance(key.wch, str) and key.wch.lower() in opts:
|
||||
return key.wch.lower()
|
||||
|
||||
def prompt(
|
||||
self,
|
||||
|
||||
@@ -30,7 +30,8 @@ def test_replace_cancel_at_replace_string(run):
|
||||
h.await_text('cancelled')
|
||||
|
||||
|
||||
def test_replace_actual_contents(run, ten_lines):
|
||||
@pytest.mark.parametrize('key', ('y', 'Y'))
|
||||
def test_replace_actual_contents(run, ten_lines, key):
|
||||
with run(str(ten_lines)) as h, and_exit(h):
|
||||
h.press('^\\')
|
||||
h.await_text('search (to replace):')
|
||||
@@ -38,7 +39,7 @@ def test_replace_actual_contents(run, ten_lines):
|
||||
h.await_text('replace with:')
|
||||
h.press_and_enter('ohai')
|
||||
h.await_text('replace [yes, no, all]?')
|
||||
h.press('y')
|
||||
h.press(key)
|
||||
h.await_text_missing('line_0')
|
||||
h.await_text('ohai')
|
||||
h.await_text(' *')
|
||||
|
||||
Reference in New Issue
Block a user