diff --git a/babi/file.py b/babi/file.py index 566aae5..22cbfb7 100644 --- a/babi/file.py +++ b/babi/file.py @@ -464,7 +464,7 @@ class File: else: pos = max(self.file_y - margin.page_size, 0) self.y = self.file_y = pos - self._set_x_after_vertical_movement() + self.x = self.x_hint = 0 @action def page_down(self, margin: Margin) -> None: @@ -473,7 +473,7 @@ class File: else: pos = self.file_y + margin.page_size self.y = self.file_y = pos - self._set_x_after_vertical_movement() + self.x = self.x_hint = 0 # editing diff --git a/tests/features/movement_test.py b/tests/features/movement_test.py index 9309edd..78bb661 100644 --- a/tests/features/movement_test.py +++ b/tests/features/movement_test.py @@ -88,6 +88,19 @@ def test_page_up_and_page_down(run, ten_lines, page_up, page_down): h.assert_cursor_line_equals('line_9') +def test_page_up_and_page_down_x_0(run, ten_lines): + with run(str(ten_lines), height=10) as h, and_exit(h): + h.press('Right') + h.press('PageDown') + h.await_cursor_position(x=0, y=1) + h.assert_cursor_line_equals('line_6') + + h.press('Right') + h.press('PageUp') + h.await_cursor_position(x=0, y=1) + h.assert_cursor_line_equals('line_0') + + def test_page_up_page_down_size_small_window(run, ten_lines): with run(str(ten_lines), height=4) as h, and_exit(h): h.press('PageDown')