Skip to content

Commit b3cba3c

Browse files
Andersson007claude
andcommitted
fix: reset cursor only on new menu, not on refresh cycles
The previous reset (unconditional at _show_menu() entry) wiped the cursor on every KEY_F(5) refresh timeout because the refresh action causes _show_menu() to return and be immediately re-called. Track _menu_current_id = id(current): reset _menu_cursor_pos only when the menu data object changes (new screen), preserving it across refresh cycles on the same screen. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent e91df3c commit b3cba3c

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

  • src/ansible_navigator/ui_framework

src/ansible_navigator/ui_framework/ui.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,9 @@ def __init__(
207207
# Cursor position in menus; None means cursor is not yet active.
208208
# It activates (becomes an int) only after the user presses UP or DOWN.
209209
self._menu_cursor_pos: int | None = None
210+
# Tracks the identity of the current menu's data object so the cursor
211+
# is reset only when entering a new menu, not on refresh cycles.
212+
self._menu_current_id: int | None = None
210213

211214
def clear(self) -> None:
212215
"""Clear the screen."""
@@ -923,7 +926,10 @@ def _show_menu(
923926
Returns:
924927
Interaction with the user
925928
"""
926-
self._menu_cursor_pos = None
929+
# Reset cursor only when entering a new menu, not on refresh cycles
930+
if id(current) != self._menu_current_id:
931+
self._menu_cursor_pos = None
932+
self._menu_current_id = id(current)
927933
while True:
928934
if self.scroll() == 0:
929935
last_line_idx = min(len(current) - 1, self._screen_height - 3)

0 commit comments

Comments
 (0)