diff --git a/src/class_cursor.py b/src/class_cursor.py index 7d82221..782d918 100644 --- a/src/class_cursor.py +++ b/src/class_cursor.py @@ -137,8 +137,11 @@ def override_passthrough(self, passthrough: T, positions: Positions) -> T: self.positions = positions return passthrough - def single_up(self) -> None: + def single_up(self, max_len: int) -> None: """Move a cursor with length 1 up by 1""" + if len(self.positions) == max_len: + self.set_to(0) + return if min(self.positions) == 0: return self.set_to(min(self.positions) - 1) @@ -154,6 +157,8 @@ def slide_up(self) -> None: def single_down(self, max_len: int) -> None: """Move a cursor with length 1 down by 1""" + if len(self.positions) == max_len: + self.set_to(min(self.positions)) if max(self.positions) >= max_len - 1: return self.set_to(max(self.positions) + 1) diff --git a/todo.py b/todo.py index 444ac9b..9719c86 100755 --- a/todo.py +++ b/todo.py @@ -610,14 +610,14 @@ def main(stdscr: curses.window) -> int: Key.h: (help_menu, "stdscr"), Key.i: (_handle_edit, "stdscr, todos, selected, single_line_state"), Key.j: (selected.single_down, "len(todos)"), - Key.k: (selected.single_up, "None"), + Key.k: (selected.single_up, "len(todos)"), Key.o: (new_todo_next, "stdscr, todos, selected, Todo(), single_line_state"), Key.p: (_handle_paste, "stdscr, todos, selected, copied_todo"), Key.s: (_handle_sort_menu, "stdscr, todos, selected"), Key.u: (_handle_undo, "selected, history"), Key.y: (copy_todo, "stdscr, todos, selected, copied_todo"), Key.down: (selected.single_down, "len(todos)"), - Key.up: (selected.single_up, "None"), + Key.up: (selected.single_up, "len(todos)"), Key.delete: (_toggle_todo_note, "todos, selected"), Key.shift_tab_windows: (_handle_dedent, "todos, selected"), Key.shift_tab: (_handle_dedent, "todos, selected"),