Skip to content

Trait item completions could work better #11860

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

Closed
4 tasks done
jonas-schievink opened this issue Mar 31, 2022 · 1 comment · Fixed by #11969
Closed
4 tasks done

Trait item completions could work better #11860

jonas-schievink opened this issue Mar 31, 2022 · 1 comment · Fixed by #11969
Labels
A-completion autocompletion C-bug Category: bug S-actionable Someone could pick this issue up and work on it right now

Comments

@jonas-schievink
Copy link
Contributor

jonas-schievink commented Mar 31, 2022

Given this code:

trait Tr {
    type Ty;
    const KONST: u8;
    fn required();
    fn provided() {}
}

impl Tr for () {
    $0
}

The completion we provide are generally pretty bad:

  • Requesting completions at $0 without typing anything else just shows generic completions. We should prioritize completions of missing trait items to be at the very top there.
    • (in fact I cannot find them in the list at all, do they only show up if at least one character is typed?)
  • Replacing $0 with fn and then requesting completions shows nothing. Instead, both required and provided should show up.
    • (the same happens when typing other keywords)
  • Applying the completion for Ty and KONST does not complete the required ; at the end, but the fn completions do include the function body and place the cursor inside.
  • Impl items generated by macros are still suggested.
@jonas-schievink jonas-schievink added A-completion autocompletion S-actionable Someone could pick this issue up and work on it right now labels Mar 31, 2022
@Veykril
Copy link
Member

Veykril commented Mar 31, 2022

Replacing $0 with fn and then requesting completions shows nothing. Instead, both required and provided should show up.

That's probably #11467

@flodiebold flodiebold added the C-bug Category: bug label Mar 31, 2022
bors bot added a commit that referenced this issue Apr 8, 2022
11938: feat: improve assoc. item completion in trait impls r=jonas-schievink a=jonas-schievink

Account for macro-generated items, increase the score of these completions since they're very relevant, and allow them to trigger when the cursor is directly in the assoc. item list without requiring further input.

![screenshot-2022-04-08-18:12:06](https://user-images.githubusercontent.com/1786438/162481277-2a0d2f21-dc20-4452-804d-6370766216b6.png)

Part of #11860

bors r+

Co-authored-by: Jonas Schievink <[email protected]>
bors bot added a commit that referenced this issue Apr 8, 2022
11938: feat: improve assoc. item completion in trait impls r=jonas-schievink a=jonas-schievink

Account for macro-generated items, increase the score of these completions since they're very relevant, and allow them to trigger when the cursor is directly in the assoc. item list without requiring further input.

![screenshot-2022-04-08-18:12:06](https://user-images.githubusercontent.com/1786438/162481277-2a0d2f21-dc20-4452-804d-6370766216b6.png)

Part of #11860

bors r+

Co-authored-by: Jonas Schievink <[email protected]>
bors bot added a commit that referenced this issue Apr 12, 2022
11967: fix: Fix trait impl completions not triggering after `fn`/`const`/`type` r=jonas-schievink a=jonas-schievink

![screenshot-2022-04-12-17:13:01](https://user-images.githubusercontent.com/1786438/162996087-56540f5e-a6be-4111-a4a5-8de21f483a5e.png)

Fixes #11467
cc #11860

bors r+

Co-authored-by: Jonas Schievink <[email protected]>
bors bot added a commit that referenced this issue Apr 12, 2022
11967: fix: Fix trait impl completions not triggering after `fn`/`const`/`type` r=jonas-schievink a=jonas-schievink

![screenshot-2022-04-12-17:13:01](https://user-images.githubusercontent.com/1786438/162996087-56540f5e-a6be-4111-a4a5-8de21f483a5e.png)

Fixes #11467
cc #11860

bors r+

Co-authored-by: Jonas Schievink <[email protected]>
bors bot added a commit that referenced this issue Apr 12, 2022
11969: fix: Add trailing `;` when completing assoc const/type in trait impl r=jonas-schievink a=jonas-schievink

Final item of #11860, thus closes #11860 🎉 

bors r+

Co-authored-by: Jonas Schievink <[email protected]>
@bors bors bot closed this as completed in #11969 Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-completion autocompletion 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.

3 participants