Skip to content

Conversation

@kuy
Copy link
Contributor

@kuy kuy commented May 24, 2020

Closes #4510

Goal

When I select a function/method from completions, I get a snippet that doesn't contain leading underscores of argument names.

Solution

  • Option 1: All signatures don't contain underscores
  • Option 2: Keep same signature, but inserted snippet doesn't contain underscores

I choose Option 2 because I think that leading underscores is a part of "signature". Users should get correct signatures. On the other hand, trimming underscores is an assist by IDE.

Other impls.

rls: Complete argument names with underscores (same as actual ra)
IntelliJ Rust: Doesn't complete argument names
VSCode (TypeScript): Doesn't complete argument names

Working example

Screen Shot 2020-05-25 at 0 03 21

@lnicola
Copy link
Member

lnicola commented May 25, 2020

Is FunctionSignature only used for completion?

@kuy
Copy link
Contributor Author

kuy commented May 25, 2020

@lnicola Ah, I shouldn't modified FunctionSignature directly... thanks for comment. I'll strip underscores in the presentation layer of completion: Completions::add_function(...)

https://github.com/rust-analyzer/rust-analyzer/blob/00172d0b555d22a42a2cbf8785eb7b2592507c4f/crates/ra_ide/src/completion/presentation.rs#L210-L215

@kuy kuy force-pushed the strip-underscore branch from 3dadccf to fd83f46 Compare May 25, 2020 16:07
@kuy
Copy link
Contributor Author

kuy commented May 25, 2020

Fixed!

@matklad
Copy link
Contributor

matklad commented May 27, 2020

bors r+

@bors
Copy link
Contributor

bors bot commented May 27, 2020

@bors bors bot merged commit 59adc7b into rust-lang:master May 27, 2020
@kuy kuy deleted the strip-underscore branch May 27, 2020 13:41
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.

Strip underscores from function arguments for completion

3 participants