feat: Implement thin-arrow completion in fn return position#21012
feat: Implement thin-arrow completion in fn return position#21012ChayimFriedman2 merged 4 commits intorust-lang:masterfrom
Conversation
75387d9 to
e7bc867
Compare
e7bc867 to
3f1b4ba
Compare
3f1b4ba to
fdc2bee
Compare
| match ret_type.ty() { | ||
| Some(ast::Type::PathType(path_ty)) => { | ||
| path_ty.path().is_some_and(|path| path.as_single_name_ref().is_some()) | ||
| } | ||
| Some(_) => false, | ||
| None => true, | ||
| } |
There was a problem hiding this comment.
Why is this? Is there a problem completing an arrow on e.g. fn foo() bar::baz| {}?
There was a problem hiding this comment.
Usually, arrows are completed when input bar
Moreover, when completing foo::bar, the range is bar instead of foo::bar, so adding arrows before requires TextEdit, which is a bit troublesome
There was a problem hiding this comment.
You can add the arrow after the ).
There was a problem hiding this comment.
So this requires TextEdit, but using TextEdit seems to be a good solution as well
| fn x() u$0 | ||
| "#, | ||
| expect![[r#" | ||
| en Enum Enum |
There was a problem hiding this comment.
IMO we should visibly render the -> in the label.
There was a problem hiding this comment.
This is difficult to complete, the editor needs to make the matching skip the arrow
There was a problem hiding this comment.
Did you mean to comment on my other comment?
There was a problem hiding this comment.
No
fo
foo
^^
Better than this:
fo
-> foo
^^
Some editors do not even support such completion
There was a problem hiding this comment.
The label can be whatever we want.
There was a problem hiding this comment.
But the editor will use the current input to match the label, and the strange prefix makes it difficult to match
There was a problem hiding this comment.
CompletionItem::lookup can control the filtering.
There was a problem hiding this comment.
Another question, if the label has an arrow, it can sometimes be strange:
mod foo {}
fn bar() foo::bar$0 {}
Outputs label -> bar, but complete bar, this is a bit counterintuitive
Perhaps you can refer to auto import, outputs label bar(adds ->)
There was a problem hiding this comment.
Right, that's better.
Very cool feature that can quickly complete simple return types Example --- ```rust fn foo() u$0 ``` **Before this PR** ```text kw where ``` **After this PR** ```text bt u32 (adds ->) u32 kw where ... ``` ```rust fn foo() -> u32 ```
fdc2bee to
1569397
Compare
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
Very cool feature that can quickly complete simple return types
Close #20885
Example
Before this PR
After this PR