Skip to content

Conversation

valadaptive
Copy link
Contributor

@valadaptive valadaptive commented Apr 4, 2025

Resolves #298.

This bit of code was apparently here to ensure the cursor moved down a line when you typed a newline, but I've tested it (with both cursor affinities, and around wrapped lines) and didn't observe any change in behavior with it removed.

Since having this code here breaks RTL text navigation, and doesn't seem to do anything else, I think it can be removed now.

There is some weird (probably incorrect) behavior around inserting newlines within an RTL span--as far as I can tell, all of that behavior is pre-existing, and occurs with or without this code present. I'll file a new issue about that. (After testing how browsers behave in this scenario, this appears to just be how it works. Bidirectional text is weird.)

@valadaptive valadaptive requested review from xorgy and DJMcNab April 4, 2025 12:19
Copy link
Member

@DJMcNab DJMcNab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree; I can understand both:

  • Why this code made sense in the model we used before #170
  • Why this code is no longer needed - it's the code around
    if left.is_end_of_line() {
    if left.is_soft_line_break() {
    let (cluster, at_end) = if left.is_rtl()
    && self.affinity == Affinity::Downstream
    || !left.is_rtl() && self.affinity == Affinity::Upstream
    {
    (left, true)
    } else {
    (right, false)
    };
    cursor_rect(&cluster, at_end, width)

Copy link
Member

@xorgy xorgy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm satisfied this is an improvement and not a regression. 👍

@valadaptive valadaptive added this pull request to the merge queue Apr 4, 2025
Merged via the queue into linebender:main with commit 7f62c26 Apr 4, 2025
21 checks passed
@valadaptive valadaptive deleted the no-affinity-reset branch April 4, 2025 18:09
@DJMcNab
Copy link
Member

DJMcNab commented Apr 5, 2025

We're not really good with testing discipline, but it would be good to land a test for #298.
It can probably be one of the usual cursor movement tests.

@xStrom xStrom added this to the 0.4 Release milestone May 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Backwards cursor navigation gets stuck in a loop with RTL text + newline
4 participants