Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change of behavour of Right command for 1 space at the start of line #242

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion babi/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def ctrl_right(self, dim: Dim) -> None:
# if we're inside the line, jump to next position that's not our type
else:
self.buf.right(dim)
tp = line[self.buf.x].isalnum()
tp = line[self.buf.x].isalnum() and line[self.buf.x - 1] != '\t'
while self.buf.x < len(line) and tp == line[self.buf.x].isalnum():
self.buf.right(dim)

Expand Down
63 changes: 63 additions & 0 deletions tests/features/movement_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,3 +545,66 @@ def another_test():

h.press('M-Down')
h.await_cursor_position(x=0, y=12)


def test_ctrl_right_jump_with_tabs(run, tmpdir):
src = '''\
\tHello\tWorld
\t\tGoodday
hi\t\tAnthonk
as\tHello
Helloa\tdsa\tasd
\t\t\tthis(is_some_code) # comment
'''
f = tmpdir.join('f')
f.write(src)
with run(str(f)) as h, and_exit(h):
h.press('^Right')
h.await_cursor_position(x=4, y=1)
h.press('^Right')
h.await_cursor_position(x=9, y=1)
h.press('Left')
h.await_cursor_position(x=8, y=1)
h.press('^Right')
h.await_cursor_position(x=12, y=1)
h.press('^Right')
h.await_cursor_position(x=17, y=1)
h.press('^Right')
h.await_cursor_position(x=8, y=2)
h.press('^Right')
h.await_cursor_position(x=15, y=2)
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=8, y=3)
h.press('^Right')
h.await_cursor_position(x=15, y=3)
h.press('^Right')
h.await_cursor_position(x=0, y=4)
h.press('^Right')
h.await_cursor_position(x=2, y=4)
h.press('Left')
h.await_cursor_position(x=1, y=4)
h.press('^Right')
h.await_cursor_position(x=4, y=4)
h.press('^Right')
h.await_cursor_position(x=9, y=4)
h.press('^Right')
h.await_cursor_position(x=0, y=5)
h.press('^Right')
h.await_cursor_position(x=6, 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('^Right')
h.await_cursor_position(x=12, y=5)
h.press('^Right')
h.await_cursor_position(x=15, y=5)
h.press('^Right')
h.await_cursor_position(x=12, y=6)
h.press('Down')
h.press('^Right')
h.await_cursor_position(x=0, y=7)