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

jump-by-word (^+right) goes too far when tabs are involved #237

Open
asottile opened this issue Apr 13, 2022 · 13 comments
Open

jump-by-word (^+right) goes too far when tabs are involved #237

asottile opened this issue Apr 13, 2022 · 13 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@asottile
Copy link
Owner

compare the following press ^+right when cursor is at left edge depending on whether it's a tab or a space

   word-here
   ^    ^
   |    + tabs stop here
   + spaces stops here
@asottile asottile added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Apr 13, 2022
@murtadapy
Copy link

I would like to take this issue, but I'm not totally sure if I get it right. May you please explain it a bit more?

@asottile
Copy link
Owner Author

^-right from beginning of the line goes to the wrong place when the line is indented with a tab -- it should go to the same position as if the line were indented with spaces

@murtadapy
Copy link

I couldn't reproduce this, it seems just the same for me. I tested it on the given example above and one on a random example

@asottile
Copy link
Owner Author

do you have an actual tab character?

@murtadapy
Copy link

Yes, I do. Probably I'm doing something wrong!

@asottile
Copy link
Owner Author

try these two (press ^Right after opening either of them)

babi +2 - <<< $'\n\thello world\n\n    hello world\n'
babi +4 - <<< $'\n\thello world\n\n    hello world\n'

@murtadapy
Copy link

First:
2

Second:
4

@asottile
Copy link
Owner Author

yeah see how they are not the same?

@murtadapy
Copy link

Oh, I get it now. That was so hard to notice for me!

@murtadapy
Copy link

I tried to run Pytest before changing anything just to ensure that everything is working fine before I start but I get the following for some reason:
E FileNotFoundError: [Errno 2] No such file or directory: 'tmux'

Also, I should not trust test_ctrl_right_jump_by_word after changing right?

@asottile
Copy link
Owner Author

going to assume you're new to software development -- usually the response to "No such file or directory: X" should be to figure out why you don't have X

the existing tests should all pass after your change

@murtadapy
Copy link

murtadapy commented Apr 22, 2022

Clearly, the issue is from line 378 or it's because of the wrong value of comparison between tp and the current x. I tried to remove that and it was working fine for me, though I cannot ensure that will be right for all cases since I'm still not able to run the tests because of a problem with Hecate.

babi/babi/file.py

Lines 376 to 381 in c51484c

# 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()
while self.buf.x < len(line) and tp == line[self.buf.x].isalnum():
self.buf.right(dim)

@Marsma13
Copy link

Marsma13 commented May 4, 2022

As Murtada-Altarouti stop working on this issue. I want to ask what is expected behaviour on this?
Couse now tab works the same as single space. And the code works becouse we normally use 4 spaces.
What should happen when we have \t\t in our code editor?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants