Skip to content

Commit dcac498

Browse files
gh-142318: Fix typing 'q' at interactive help screen exiting Tachyon (#142319)
1 parent 59f247e commit dcac498

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

Lib/profiling/sampling/live_collector/collector.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -861,10 +861,12 @@ def _handle_input(self):
861861
# Handle help toggle keys
862862
if ch == ord("h") or ch == ord("H") or ch == ord("?"):
863863
self.show_help = not self.show_help
864+
return
864865

865866
# If showing help, any other key closes it
866-
elif self.show_help and ch != -1:
867+
if self.show_help and ch != -1:
867868
self.show_help = False
869+
return
868870

869871
# Handle regular commands
870872
if ch == ord("q") or ch == ord("Q"):

Lib/test/test_profiling/test_sampling_profiler/test_live_collector_interaction.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,19 @@ def test_help_with_question_mark(self):
173173

174174
self.assertTrue(self.collector.show_help)
175175

176+
def test_help_dismiss_with_q_does_not_quit(self):
177+
"""Test that pressing 'q' while help is shown only closes help, not quit"""
178+
self.assertFalse(self.collector.show_help)
179+
self.display.simulate_input(ord("h"))
180+
self.collector._handle_input()
181+
self.assertTrue(self.collector.show_help)
182+
183+
self.display.simulate_input(ord("q"))
184+
self.collector._handle_input()
185+
186+
self.assertFalse(self.collector.show_help)
187+
self.assertTrue(self.collector.running)
188+
176189
def test_filter_clear(self):
177190
"""Test clearing filter."""
178191
self.collector.filter_pattern = "test"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix typing ``'q'`` at the help of the interactive tachyon profiler exiting
2+
the profiler.

0 commit comments

Comments
 (0)