Ensure PageUp and PageDown go to beginning of line

This commit is contained in:
Anthony Sottile
2020-02-29 16:09:34 -08:00
parent c248fb2d50
commit e365580985
2 changed files with 15 additions and 2 deletions

View File

@@ -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

View File

@@ -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')