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

Unexpected behaviour with find_till_char when on last character of a non-empty line #4065

Closed
peter9477 opened this issue Oct 1, 2022 · 4 comments
Labels
C-bug Category: This is a bug

Comments

@peter9477
Copy link

peter9477 commented Oct 1, 2022

Summary

Using t (find_till_char) with Enter when on the last character of a line behaves unexpectedly. If on a line where the following line is completely empty it appears to work, but if the following line is non-empty then it actually selects until the end of that line, not the one you're on.

Reproduction Steps

Using this example:

line1
line2

line4
x
line6

Place cursor on 1 and t Enter and you select up to 2. Place cursor on 2 and it selects just the 2 (as expected). Cursor on line 3 and it selects till 4 (also as expected). Cursor on 4 behaves (incorrectly?) like 1. Cursor on 5 (i.e. the x) selects till 6 (also not

Platform

Linux

Terminal Emulator

putty

Helix Version

22.08.1-125-g5b5f1bd3

@peter9477 peter9477 added the C-bug Category: This is a bug label Oct 1, 2022
@peter9477
Copy link
Author

Note that while what I might consider "expected" may not be the actual intended behaviour, if you go through my test cases I'm pretty sure you'll agree there's some sort of inconsistency going on, so something unexpected in any case. Surely how it behaves on a given line should not be affected by the contents of the following line.

@Omnikar
Copy link
Contributor

Omnikar commented Oct 2, 2022

There doesn't seem to be any inconsistent behaviour here; if we think of the newlines as any other character and view the example as one line:
Place cursor on 1.

line[1]⏎line2⏎⏎line4⏎x⏎line6⏎

t⏎ extends the selection until the second .

line(1⏎line2]⏎⏎line4⏎x⏎line6⏎

Place the cursor on 2.

line1⏎line[2]⏎⏎line4⏎x⏎line6⏎

t⏎ extends the selection until the third .

line1⏎line(2⏎]⏎line4⏎x⏎line6⏎

Place the cursor on the third line, on the third .

line1⏎line2⏎[⏎]line4⏎x⏎line6⏎

t⏎ extends the selection until the fourth .

line1⏎line2⏎(⏎line4]⏎x⏎line6⏎

Place the cursor on 4.

line1⏎line2⏎⏎line[4]⏎x⏎line6⏎

t⏎ extends the selection until the fifth .

line1⏎line2⏎⏎line(4⏎x]⏎line6⏎

Place the cursor on x.

line1⏎line2⏎⏎line4⏎[x]⏎line6⏎

t⏎ extends the selection until the last .

line1⏎line2⏎⏎line4⏎(x⏎line6]⏎

@the-mikedavis
Copy link
Member

The part of this I thought was buggy: t's behavior is a little different than how it works with Kakoune, specifically:

line#[1|]#
line2

in Helix gives

line#[1
line2|]#

where in Kakoune it gives

line#[1|]#
line2

Helix moves to the next next instance if the next instance follows immediately and Kakoune does not (see this block).

It looks like this is an intentional difference though: #891 (comment).

So @Omnikar's explanation is spot-on 👍

@the-mikedavis the-mikedavis closed this as not planned Won't fix, can't repro, duplicate, stale Oct 2, 2022
@peter9477
Copy link
Author

peter9477 commented Oct 3, 2022

Thanks guys. The fundamental problem here was me continuing to think of the "find till" selection as directly involving the character (in this case newline) rather than selecting up to the character, and not paying close attention to the subtle difference in behaviour between when it selects the current line's newline because it's selecting up to the newline on the following blank line, vs when it's earlier on the line and just selects till but not including the current line's newline. Turning on render.newline = "all" made this much clearer and I accept that what it does is in fact consistent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug
Projects
None yet
Development

No branches or pull requests

3 participants