mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 12:29:21 +00:00
Fix rename test fixtures not accounting for multi file edits
This commit is contained in:
parent
9bd9a17ce5
commit
507448652a
1 changed files with 12 additions and 13 deletions
|
@ -372,7 +372,7 @@ mod tests {
|
||||||
use test_utils::assert_eq_text;
|
use test_utils::assert_eq_text;
|
||||||
use text_edit::TextEdit;
|
use text_edit::TextEdit;
|
||||||
|
|
||||||
use crate::{fixture, FileId};
|
use crate::fixture;
|
||||||
|
|
||||||
use super::{RangeInfo, RenameError};
|
use super::{RangeInfo, RenameError};
|
||||||
|
|
||||||
|
@ -400,19 +400,18 @@ mod tests {
|
||||||
match rename_result {
|
match rename_result {
|
||||||
Ok(source_change) => {
|
Ok(source_change) => {
|
||||||
let mut text_edit_builder = TextEdit::builder();
|
let mut text_edit_builder = TextEdit::builder();
|
||||||
let mut file_id: Option<FileId> = None;
|
let (&file_id, edit) = match source_change.source_file_edits.len() {
|
||||||
for edit in source_change.source_file_edits {
|
0 => return,
|
||||||
file_id = Some(edit.0);
|
1 => source_change.source_file_edits.iter().next().unwrap(),
|
||||||
for indel in edit.1 .0.into_iter() {
|
_ => (&position.file_id, &source_change.source_file_edits[&position.file_id]),
|
||||||
text_edit_builder.replace(indel.delete, indel.insert);
|
};
|
||||||
|
for indel in edit.0.iter() {
|
||||||
|
text_edit_builder.replace(indel.delete, indel.insert.clone());
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if let Some(file_id) = file_id {
|
|
||||||
let mut result = analysis.file_text(file_id).unwrap().to_string();
|
let mut result = analysis.file_text(file_id).unwrap().to_string();
|
||||||
text_edit_builder.finish().apply(&mut result);
|
text_edit_builder.finish().apply(&mut result);
|
||||||
assert_eq_text!(ra_fixture_after, &*result);
|
assert_eq_text!(ra_fixture_after, &*result);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
if ra_fixture_after.starts_with("error:") {
|
if ra_fixture_after.starts_with("error:") {
|
||||||
let error_message =
|
let error_message =
|
||||||
|
@ -2649,7 +2648,7 @@ pub struct S;
|
||||||
//- /main.rs crate:main deps:lib new_source_root:local
|
//- /main.rs crate:main deps:lib new_source_root:local
|
||||||
use lib::S$0;
|
use lib::S$0;
|
||||||
"#,
|
"#,
|
||||||
"use lib::Baz;",
|
"use lib::Baz;\n",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue