Skip to content

Conversation

@syvb
Copy link
Contributor

@syvb syvb commented Apr 22, 2021

This makes pressing | while some text is selected surround that text with pipes. This is useful when writing closures.

In this demo, I press | to easily surround some text (predicate) with pipe characters to create a closure. Before, this would have replaced predicate with just |.

(I am getting failures when I do cargo test even on master locally (due to #8585 I think), but GH Actions is fine with this)

@matklad
Copy link
Contributor

matklad commented Apr 23, 2021

Hm, I guess I am OK with it, but this is papering over a gaping hole in our UX. I think we should:

  • forcefully trigger completion when the cursor is in the position of an argument of a closure typer
  • suggest |param1, param2| $0 as a completion variant

@matklad
Copy link
Contributor

matklad commented Apr 23, 2021

Alternatively, we can show two completion variants for filter:

filter(...)
filter(|x| ...)

@flodiebold
Copy link
Member

flodiebold commented Apr 23, 2021

IMO completing |x| $0 when you type | would be enough? Making | surround wouldn't actually help with that.

(The actual completion should depend on the expected closure type, of course.)

(We could/should also complete the corresponding move |x| $0...)

@matklad
Copy link
Contributor

matklad commented Apr 27, 2021

bors r+

@bors
Copy link
Contributor

bors bot commented Apr 27, 2021

@bors bors bot merged commit e2b8773 into rust-lang:master Apr 27, 2021
@lnicola
Copy link
Member

lnicola commented Apr 28, 2021

changelog feat (first contribution) allow pressing | to surround closure arguments in VS Code

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.

4 participants