-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add Unmerge Use assist #7289
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
Add Unmerge Use assist #7289
Conversation
| let new_use = ast::make::use_( | ||
| use_.visibility(), | ||
| ast::make::use_tree(path, None, tree.rename(), tree.star_token().is_some()), | ||
| ); | ||
|
|
||
| let mut rewriter = SyntaxRewriter::default(); | ||
| rewriter += tree.remove(); | ||
| rewriter.insert_after(use_.syntax(), &ast::make::tokens::single_newline()); | ||
| if let ident_level @ 1..=usize::MAX = use_.indent_level().0 as usize { | ||
| rewriter.insert_after( | ||
| use_.syntax(), | ||
| &ast::make::tokens::whitespace(&" ".repeat(4 * ident_level)), | ||
| ); | ||
| } | ||
| rewriter.insert_after(use_.syntax(), new_use.syntax()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part should go into the |builder| closure, to avoid unnecessary computation.
matklad
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me with a test mark!
bors r+
| if tree_list.use_trees().count() < 2 { | ||
| return None; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this could use mark::hit! call (see the mark module).
|
ah, this should've been d+ could you send a followup? |
|
sent it #7290 |
Closes #7185