Skip to content

Commit 59b0e34

Browse files
Kasper JungeRalphify
authored andcommitted
refactor: inline _fullscreen_page_size() into space/b lambdas
The `page` local in `_handle_fullscreen_key` was computed unconditionally in the non-exit branch but only consumed by the space/b action lambdas (page-down / page-up). Inlining `self._fullscreen_page_size()` into those two lambdas means it's only evaluated when space or b is actually pressed — j/k/g/G/[/] now skip the call entirely. Behavior is identical: the dict is built and a single action is invoked per keypress, and the page value is read at action-invocation time under the same lock. Same Phase 4 shape as 134078d / ef176bf / b19625e — narrow the scope of a local that was only live on one branch. Co-authored-by: Ralphify <noreply@ralphify.co>
1 parent b2a4e4c commit 59b0e34

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

src/ralphify/_console_emitter.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,12 +1441,11 @@ def _handle_fullscreen_key(self, key: str) -> None:
14411441
if view is None:
14421442
return # raced with exit
14431443
if key not in ("q", FULLSCREEN_PEEK_KEY):
1444-
page = self._fullscreen_page_size()
14451444
actions: dict[str, Callable[[], object]] = {
14461445
"j": lambda: view.scroll_down(1),
14471446
"k": lambda: view.scroll_up(1),
1448-
" ": lambda: view.scroll_down(page),
1449-
"b": lambda: view.scroll_up(page),
1447+
" ": lambda: view.scroll_down(self._fullscreen_page_size()),
1448+
"b": lambda: view.scroll_up(self._fullscreen_page_size()),
14501449
"g": view.scroll_to_top,
14511450
"G": view.scroll_to_bottom,
14521451
PREV_ITERATION_KEY: view.prev_iteration,

0 commit comments

Comments
 (0)