fix: Improve "n" key navigation for change blocks
This commit is contained in:
parent
229a1e9360
commit
a86704e531
18
gtm
18
gtm
|
|
@ -297,8 +297,15 @@ def jump_to_next_change(state: AppState) -> AppState:
|
||||||
if not state.change_blocks:
|
if not state.change_blocks:
|
||||||
return state
|
return state
|
||||||
|
|
||||||
# Find the next change block after current position
|
# Find the next change block after current position or current change index
|
||||||
current_pos = state.right_scroll_offset
|
current_pos = state.right_scroll_offset
|
||||||
|
current_idx = state.current_change_idx
|
||||||
|
|
||||||
|
# If we're already on a change block, try to move to the next one
|
||||||
|
if current_idx != -1:
|
||||||
|
next_idx = (current_idx + 1) % len(state.change_blocks)
|
||||||
|
else:
|
||||||
|
# Otherwise find the next change block after current scroll position
|
||||||
next_idx = -1
|
next_idx = -1
|
||||||
for i, (start_pos, _) in enumerate(state.change_blocks):
|
for i, (start_pos, _) in enumerate(state.change_blocks):
|
||||||
if start_pos > current_pos:
|
if start_pos > current_pos:
|
||||||
|
|
@ -320,8 +327,15 @@ def jump_to_prev_change(state: AppState) -> AppState:
|
||||||
if not state.change_blocks:
|
if not state.change_blocks:
|
||||||
return state
|
return state
|
||||||
|
|
||||||
# Find the previous change block before current position
|
# Find the previous change block before current position or current change index
|
||||||
current_pos = state.right_scroll_offset
|
current_pos = state.right_scroll_offset
|
||||||
|
current_idx = state.current_change_idx
|
||||||
|
|
||||||
|
# If we're already on a change block, try to move to the previous one
|
||||||
|
if current_idx != -1:
|
||||||
|
prev_idx = (current_idx - 1) % len(state.change_blocks)
|
||||||
|
else:
|
||||||
|
# Otherwise find the previous change block before current scroll position
|
||||||
prev_idx = -1
|
prev_idx = -1
|
||||||
for i in range(len(state.change_blocks) - 1, -1, -1):
|
for i in range(len(state.change_blocks) - 1, -1, -1):
|
||||||
if state.change_blocks[i][0] < current_pos:
|
if state.change_blocks[i][0] < current_pos:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue