Implement jump by word (^Left/^Right)
This commit is contained in:
@@ -267,3 +267,83 @@ def test_page_up_does_not_go_negative(ten_lines):
|
||||
h.press('^Y')
|
||||
h.await_cursor_position(x=0, y=1)
|
||||
assert h.get_cursor_line() == 'line_0'
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def jump_word_file(tmpdir):
|
||||
f = tmpdir.join('f')
|
||||
contents = '''\
|
||||
hello world
|
||||
|
||||
hi
|
||||
|
||||
this(is_some_code) # comment
|
||||
'''
|
||||
f.write(contents)
|
||||
yield f
|
||||
|
||||
|
||||
def test_ctrl_right_jump_by_word(jump_word_file):
|
||||
with run(str(jump_word_file)) as h, and_exit(h):
|
||||
h.press('^Right')
|
||||
h.await_cursor_position(x=5, y=1)
|
||||
h.press('^Right')
|
||||
h.await_cursor_position(x=11, y=1)
|
||||
h.press('Left')
|
||||
h.await_cursor_position(x=10, y=1)
|
||||
h.press('^Right')
|
||||
h.await_cursor_position(x=11, y=1)
|
||||
h.press('^Right')
|
||||
h.await_cursor_position(x=0, y=3)
|
||||
h.press('^Right')
|
||||
h.await_cursor_position(x=2, y=3)
|
||||
h.press('^Right')
|
||||
h.await_cursor_position(x=4, y=5)
|
||||
h.press('^Right')
|
||||
h.await_cursor_position(x=8, y=5)
|
||||
h.press('^Right')
|
||||
h.await_cursor_position(x=11, y=5)
|
||||
h.press('Down')
|
||||
h.press('^Right')
|
||||
h.await_cursor_position(x=0, y=6)
|
||||
|
||||
|
||||
def test_ctrl_left_jump_by_word(jump_word_file):
|
||||
with run(str(jump_word_file)) as h, and_exit(h):
|
||||
h.press('^Left')
|
||||
h.await_cursor_position(x=0, y=1)
|
||||
h.press('Right')
|
||||
h.await_cursor_position(x=1, y=1)
|
||||
h.press('^Left')
|
||||
h.await_cursor_position(x=0, y=1)
|
||||
h.press('PageDown')
|
||||
h.await_cursor_position(x=0, y=6)
|
||||
h.press('^Left')
|
||||
h.await_cursor_position(x=33, y=5)
|
||||
h.press('^Left')
|
||||
h.await_cursor_position(x=26, y=5)
|
||||
h.press('Home')
|
||||
h.press('Right')
|
||||
h.await_cursor_position(x=1, y=5)
|
||||
h.press('^Left')
|
||||
h.await_cursor_position(x=2, y=3)
|
||||
|
||||
|
||||
def test_ctrl_right_triggering_scroll(jump_word_file):
|
||||
with run(str(jump_word_file), height=4) as h, and_exit(h):
|
||||
h.press('Down')
|
||||
h.await_cursor_position(x=0, y=2)
|
||||
h.press('^Right')
|
||||
h.await_cursor_position(x=0, y=1)
|
||||
assert h.get_cursor_line() == 'hi'
|
||||
|
||||
|
||||
def test_ctrl_left_triggering_scroll(jump_word_file):
|
||||
with run(str(jump_word_file)) as h, and_exit(h):
|
||||
h.press('Down')
|
||||
h.await_cursor_position(x=0, y=2)
|
||||
h.press('^Down')
|
||||
h.await_cursor_position(x=0, y=1)
|
||||
h.press('^Left')
|
||||
h.await_cursor_position(x=11, y=1)
|
||||
assert h.get_cursor_line() == 'hello world'
|
||||
|
||||
@@ -46,6 +46,28 @@ def test_replace_actual_contents(ten_lines):
|
||||
h.await_text('replaced 1 occurrence')
|
||||
|
||||
|
||||
def test_replace_sets_x_hint_properly(tmpdir):
|
||||
f = tmpdir.join('f')
|
||||
contents = '''\
|
||||
beginning_line
|
||||
|
||||
match me!
|
||||
'''
|
||||
f.write(contents)
|
||||
with run(str(f)) as h, and_exit(h):
|
||||
h.press('^\\')
|
||||
h.await_text('search (to replace):')
|
||||
h.press_and_enter('me!')
|
||||
h.await_text('replace with:')
|
||||
h.press_and_enter('youuuu')
|
||||
h.await_text('replace [y(es), n(o), a(ll)]?')
|
||||
h.press('y')
|
||||
h.await_cursor_position(x=6, y=3)
|
||||
h.press('Up')
|
||||
h.press('Up')
|
||||
h.await_cursor_position(x=6, y=1)
|
||||
|
||||
|
||||
def test_replace_cancel_at_individual_replace(ten_lines):
|
||||
with run(str(ten_lines)) as h, and_exit(h):
|
||||
h.press('^\\')
|
||||
|
||||
@@ -49,6 +49,24 @@ def test_search_only_one_match_already_at_that_match(ten_lines):
|
||||
h.await_cursor_position(x=0, y=2)
|
||||
|
||||
|
||||
def test_search_sets_x_hint_properly(tmpdir):
|
||||
f = tmpdir.join('f')
|
||||
contents = '''\
|
||||
beginning_line
|
||||
|
||||
match me!
|
||||
'''
|
||||
f.write(contents)
|
||||
with run(str(f)) as h, and_exit(h):
|
||||
h.press('^W')
|
||||
h.await_text('search:')
|
||||
h.press_and_enter('me!')
|
||||
h.await_cursor_position(x=6, y=3)
|
||||
h.press('Up')
|
||||
h.press('Up')
|
||||
h.await_cursor_position(x=6, y=1)
|
||||
|
||||
|
||||
def test_search_not_found(ten_lines):
|
||||
with run(str(ten_lines)) as h, and_exit(h):
|
||||
h.press('^W')
|
||||
|
||||
Reference in New Issue
Block a user