Skip to content
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

Assist to extract out variables assignment in if/match #7006

Closed
Veykril opened this issue Dec 22, 2020 · 1 comment
Closed

Assist to extract out variables assignment in if/match #7006

Veykril opened this issue Dec 22, 2020 · 1 comment
Labels
A-assists S-actionable Someone could pick this issue up and work on it right now

Comments

@Veykril
Copy link
Member

Veykril commented Dec 22, 2020

Given code like the following:

let mut completion = ...;
if let Some(snippet_cap) = ctx.snippet_cap() {
    completion = completion.insert_snippet(snippet_cap, pat);
} else {
    completion = completion.insert_text(pat);
}

the assist should turn it into:

let mut completion = ...;
completion = if let Some(snippet_cap) = ctx.snippet_cap() {
    completion.insert_snippet(snippet_cap, pat)
} else {
    completion.insert_text(pat)
};

cc #6964 (comment)

@Veykril Veykril added S-actionable Someone could pick this issue up and work on it right now A-assists labels Dec 22, 2020
bors bot added a commit that referenced this issue Jan 2, 2021
7130: Add extract_assignment assist r=Jesse-Bakker a=Jesse-Bakker

Add extract-assignment assist (#7006).

Assist is for now only implemented on if/match-statements where the assigment is the last statement in every block,
as for other cases, one would have to check whether the assignment has effects on the rest of the block and
extract a temporary variable for it in the block.



Co-authored-by: Jesse Bakker <github@jessebakker.com>
@Veykril
Copy link
Member Author

Veykril commented Jan 2, 2021

Fixed in #7130

@Veykril Veykril closed this as completed Jan 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-assists S-actionable Someone could pick this issue up and work on it right now
Projects
None yet
Development

No branches or pull requests

1 participant