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

vim: Add Separator and RemoveIndent in Join Lines, fix gJ use space join #22496

Merged
merged 7 commits into from
Jan 7, 2025

Conversation

0x2CA
Copy link
Contributor

@0x2CA 0x2CA commented Dec 30, 2024

Closes #22492

Release Notes:

  • Added Join Lines Separator And RemoveIndent

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Dec 30, 2024
@0x2CA 0x2CA changed the title vim:Add Separator in Join Lines,Fix gJ use space join vim:Add Separator and RemoveIndent in Join Lines,Fix gJ use space join Dec 30, 2024
@maxdeviant maxdeviant changed the title vim:Add Separator and RemoveIndent in Join Lines,Fix gJ use space join vim: Add Separator and RemoveIndent in Join Lines, fix gJ use space join Dec 31, 2024
@ConradIrwin
Copy link
Member

@0x2CA Thank you for this!

Using a struct JoinLines { ... } causes the action to not show up in the command palette. We should keep editor::JoinLines as is.

For vim it matters a bit less, so we can change that one; or we could add vim::JoinLinesNoSpace.

Is the removeIndent option needed for compatibility, or just something you thought might be useful?

Could you please also add a test for gJ:

    #[gpui::test]
    async fn test_gj(cx: &mut gpui::TestAppContext) {
        let mut cx = NeovimBackedTestContext::new(cx).await;

        cx.set_shared_state(indoc! {"
            ˇa
            b
        })
        .await;
        cx.simulate_shared_keystrokes("g shift-j").await;
        cx.shared_state().await.assert_eq(indoc! {"
            aˇb
        })
    }

You can run the test with cargo test -p vim --features neovim test_gj and commit the JSON file it generates (so that the CI machines don't need to run real neovim)

@0x2CA
Copy link
Contributor Author

0x2CA commented Jan 7, 2025

@ConradIrwin

because gJ not only separates character differences, but does not remove or insert spaces.

gJ			Join [count] lines, with a minimum of two lines.
			Don't insert or remove any spaces.

for example

a
    b
a    b

I have fixed the command and added the test.

@ConradIrwin ConradIrwin force-pushed the add_join_lines_separator branch from 4eb7333 to 0a6f97a Compare January 7, 2025 16:18
@ConradIrwin ConradIrwin added this pull request to the merge queue Jan 7, 2025
@ConradIrwin
Copy link
Member

@0x2CA Thanks for this. Thinking about it more, it's probably easiest to keep the implementation less complex (although it's less flexible). If you'd like to add a vim::JoinLinesRemoveWhitespace in addition for that use-case Id' be ok with that.

Merged via the queue into zed-industries:main with commit 4deab8a Jan 7, 2025
13 checks passed
@0x2CA
Copy link
Contributor Author

0x2CA commented Jan 8, 2025

Removing the indentation is also an essential option, which will result in the removal of spaces, and my implementation is freer to use any hyphenation, allowing the user to implement hyphens like "a_b_c_d"

@0x2CA 0x2CA deleted the add_join_lines_separator branch January 8, 2025 06:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Vim mode gJ behaves like J
2 participants