Skip to content

Commit 0d1109a

Browse files
committed
Fix indent for merge_imports
Example --- ```rust mod tests { use foo$0::bar; use foo::baz; fn feature() {} } ``` **Before this PR** ```rust mod tests { use foo::{bar, baz}; fn feature() {} } ``` **After this PR** ```rust mod tests { use foo::{bar, baz}; fn feature() {} } ```
1 parent 9d58a93 commit 0d1109a

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

crates/ide-assists/src/handlers/merge_imports.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,26 @@ use foo::{bar, baz};
563563
);
564564
}
565565

566+
#[test]
567+
fn mod_indent_whitespace() {
568+
check_assist(
569+
merge_imports,
570+
r"
571+
mod tests {
572+
use foo$0::bar;
573+
use foo::baz;
574+
fn feature() {}
575+
}
576+
",
577+
r"
578+
mod tests {
579+
use foo::{bar, baz};
580+
fn feature() {}
581+
}
582+
",
583+
);
584+
}
585+
566586
#[test]
567587
fn works_with_trailing_comma() {
568588
check_assist(

crates/syntax/src/syntax_editor/edits.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ impl Removable for ast::Use {
221221
.and_then(ast::Whitespace::cast);
222222
if let Some(next_ws) = next_ws {
223223
let ws_text = next_ws.syntax().text();
224-
if let Some(rest) = ws_text.strip_prefix('\n') {
224+
if let Some(rest) = ws_text.trim_end_matches(' ').strip_prefix('\n') {
225225
if rest.is_empty() {
226226
editor.delete(next_ws.syntax());
227227
} else {

0 commit comments

Comments
 (0)