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

feat(lsp): join multiple visually selected lines (RustLsp joinLines) #339

Merged
merged 1 commit into from
Apr 1, 2024

Conversation

mrcjkb
Copy link
Owner

@mrcjkb mrcjkb commented Apr 1, 2024

Closes #335

Copy link
Contributor

github-actions bot commented Apr 1, 2024

Review Checklist

Does this PR follow the Contribution Guidelines? Following is a partial checklist:

Proper conventional commit scoping:

  • For example, fix(lsp): some lsp-related bugfix

  • Pull request title has the appropriate conventional commit prefix.

If applicable:

  • Tested
    • Tests have been added.
    • Tested manually (Steps to reproduce in PR description).
  • Updated documentation.
  • Updated CHANGELOG.md

@mrcjkb mrcjkb enabled auto-merge (squash) April 1, 2024 16:01
@mrcjkb mrcjkb merged commit e9db3d5 into master Apr 1, 2024
8 checks passed
@mrcjkb mrcjkb deleted the joinlines branch April 1, 2024 16:02
@9mm
Copy link

9mm commented Apr 1, 2024

    if true {
        dbg!(println!("Hello, world!"));
    }
    if false {
        println!("Hello, world!");
    }

Am i doing something wrong? If i visually select the first 3 lines with <S-V> and join lines I get:

    if true { dbg!(println!("Hello, world!")); } else if false {
        println!("Hello, world!");
    }

@9mm
Copy link

9mm commented Apr 1, 2024

It seems its counting lines + 1 for the # of lines selected. selecting 2 rows gives expected result of selecting 3 rows

@mrcjkb
Copy link
Owner Author

mrcjkb commented Apr 1, 2024

It seems its counting lines + 1 for the # of lines selected. selecting 2 rows gives expected result of selecting 3 rows

I guess that's an implementation detail of rust-analyzer?
rustaceanvim just sends it the selected range and performs the text edit that rust-analyzer tells it to.

Does it behave differently in vscode?

@9mm
Copy link

9mm commented Apr 1, 2024

im not sure i dont use vscode. its not a dealbreaker i guess, but definitely is weird

@9mm
Copy link

9mm commented Apr 1, 2024

thank you for adding it though!

@mrcjkb
Copy link
Owner Author

mrcjkb commented Apr 1, 2024

Based on the gif in the rust-analyzer docs, it looks like that is the way it behaves (it's also joining the unselected whitespace line).
I guess it's because selecting a single line results in the line below being joined, so it's consistent with that?
But I agree, it's not very intuitive.

join-lines

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.

[Feature/joinLines] support joining multiple lines in visual mode
2 participants