Skip to content

Helix mode: sometimes v excludes current character from selection #38121

@romaninsh

Description

@romaninsh

Summary

Entering Helix Select mode after esc sometimes excludes current character from selection

Description

This bug is hard to explain. In helix cursor is a selection. In zed:helix we don't always keep selection open, instead some actions will default to current character if no selection is present (helix_yank #35612, or #38119).

In HelixNormal pressing v selects character under cursor and moving around will expand that selection. Original character will always remain selected if you go forward or backward. For the most part this is how selection behaves.

There is a sequence, that triggers a bug in this:

w b escape v w

going to next word and backward in Helix will keep the first word selected. Escape resets selection (like ;) then v will go to select mode and w will select next word again.

One would expect entirety of the word to be selected, but somehow the first character is excluded:

Image

I wrote a test case for this:

    #[gpui::test]
    async fn test_helix_wbvw_motions(cx: &mut gpui::TestAppContext) {
        let mut cx = VimTestContext::new(cx, true).await;
        cx.enable_helix();
        cx.set_state("ˇone two", Mode::HelixNormal);
        cx.simulate_keystrokes("v b ; v w");
        cx.assert_state("«one ˇ»two", Mode::HelixSelect);

        cx.set_state("ˇone two", Mode::HelixNormal);
        cx.simulate_keystrokes("v b escape v w");
        cx.assert_state("«one ˇ»two", Mode::HelixSelect);
    }

Strangely though - the test case passes. Also using ; instead of escape seems to work correctly.

I wonder what it is about escape and only from under cargo run that messes with selection mode.

Below are the state after each operation:

w b

Image

escape

Image

v

Image

w

Image

Expected Behavior:
entirety of the first word should be selected at the end of the sequence.

Zed Version and System Specs

Version: built from main with #38117 applied.

Mac

Config only enabling vim and helix modes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:parity/helixFeedback for Helix parity features

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions