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

"Extract into Function" removes whitespace #13874

Closed
gamma-delta opened this issue Jan 1, 2023 · 0 comments · Fixed by #13891
Closed

"Extract into Function" removes whitespace #13874

gamma-delta opened this issue Jan 1, 2023 · 0 comments · Fixed by #13891
Labels
A-assists C-bug Category: bug S-actionable Someone could pick this issue up and work on it right now

Comments

@gamma-delta
Copy link

rust-analyzer version: rust-analyzer 1.67.0-nightly (83356b7 2022-11-17)

rustc version: rustc 1.67.0-nightly (83356b78c 2022-11-17)

relevant settings: nothing out of the ordinary, I think, but I'm using this in Helix


Expected behavior: using the Extract into Function action extracts the highlighted code into a function exactly without changing whitespace/newlines.

Behavior: it removes newlines.

fn some_long_function() {
  let foo = bar();
  let bax = quux();

  // If I highlight from here ... {
  let foo2 = foo * 2;

  let frob = baz.frobnicate();
  frob.process();
  // } to here, and extract into function,
  // the newline after `let foo2 = foo*2` is removed.
}

I think it does make sense to auto-format the code because it'll format on save anyways (hopefully), but it is kind of weird for the newlines to disappear because then I have to go back and insert all the newlines again ... I'd imagine that's tricky to implement though (I don't know about rust-analyzer's internals but I'd imagine this action operates on the AST more than text).

@lnicola lnicola added S-actionable Someone could pick this issue up and work on it right now A-assists C-bug Category: bug labels Jan 1, 2023
@bors bors closed this as completed in 938a39a Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-assists C-bug Category: bug S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants