Skip to content

Allow pressing | to surround closure arguments in VSCode - #8629

Merged
bors[bot] merged 1 commit into
rust-lang:masterfrom
syvb:patch-2
Apr 27, 2021
Merged

bors[bot] merged 1 commit into
rust-lang:masterfrom
syvb:patch-2

Conversation

@syvb

@syvb syvb commented Apr 22, 2021

Copy link
Copy Markdown
Contributor

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

matklad commented Apr 23, 2021

Copy link
Copy Markdown
Contributor

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

matklad commented Apr 23, 2021

Copy link
Copy Markdown
Contributor

Alternatively, we can show two completion variants for filter:

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

@flodiebold

flodiebold commented Apr 23, 2021 •

Copy link
Copy Markdown
Member

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

matklad commented Apr 27, 2021

Copy link
Copy Markdown
Contributor

bors r+

@bors

bors Bot commented Apr 27, 2021

Copy link
Copy Markdown
Contributor

@bors
bors Bot merged commit e2b8773 into rust-lang:master Apr 27, 2021
@lnicola

lnicola commented Apr 28, 2021

Copy link
Copy Markdown
Member

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