From 26cfb17aa041951992e4881288d149d78ed48290 Mon Sep 17 00:00:00 2001 From: Silas Kraume Date: Thu, 5 Dec 2024 18:58:58 +0100 Subject: [PATCH] fix cursor column preservation --- cat_win/src/service/editor.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cat_win/src/service/editor.py b/cat_win/src/service/editor.py index b41a21a..3479433 100644 --- a/cat_win/src/service/editor.py +++ b/cat_win/src/service/editor.py @@ -1357,11 +1357,13 @@ def _enforce_boundaries(self, key: bytes) -> None: rowlen = len(self.window_content[self.cpos.row]) if( self.cpos.row < len(self.window_content) ) else 0 - if self.snap_pos.row == self.cpos.row or key not in MOVE_HOTKEYS | SELECT_HOTKEYS: - self.snap_pos.set_pos(self.cpos.get_pos()) - else: + if key in MOVE_HOTKEYS | SELECT_HOTKEYS and ( + b'_up' in key or b'_down' in key + ): self.snap_pos.row = self.cpos.row self.cpos.col = min(self.snap_pos.col, rowlen) + else: + self.snap_pos.set_pos(self.cpos.get_pos()) self.cpos.col = min(self.cpos.col, rowlen) if not self.scrolling: