mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-01 07:48:45 +00:00
fix
This commit is contained in:
parent
5d013a79d6
commit
3c898dd9a1
1 changed files with 12 additions and 11 deletions
|
@ -334,11 +334,12 @@ pub fn source_edit_from_references(
|
||||||
_ => false,
|
_ => false,
|
||||||
};
|
};
|
||||||
if !has_emitted_edit && !edited_ranges.contains(&range.start()) {
|
if !has_emitted_edit && !edited_ranges.contains(&range.start()) {
|
||||||
let new_name = match name {
|
let (range, new_name) = match name {
|
||||||
ast::NameLike::Lifetime(_) => {
|
ast::NameLike::Lifetime(_) => (
|
||||||
format!("'{}", new_name.trim_start_matches("'"))
|
TextRange::new(range.start() + syntax::TextSize::from(1), range.end()),
|
||||||
}
|
new_name.strip_prefix('\'').unwrap_or(new_name).to_owned(),
|
||||||
_ => new_name.into(),
|
),
|
||||||
|
_ => (range, new_name.to_owned()),
|
||||||
};
|
};
|
||||||
|
|
||||||
edit.replace(range, new_name);
|
edit.replace(range, new_name);
|
||||||
|
@ -507,14 +508,14 @@ fn source_edit_from_def(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if edit.is_empty() {
|
if edit.is_empty() {
|
||||||
let new_name = match def {
|
let (range, new_name) = match def {
|
||||||
Definition::GenericParam(hir::GenericParam::LifetimeParam(_))
|
Definition::GenericParam(hir::GenericParam::LifetimeParam(_))
|
||||||
| Definition::Label(_) => {
|
| Definition::Label(_) => (
|
||||||
format!("'{}", new_name.trim_start_matches("'"))
|
TextRange::new(range.start() + syntax::TextSize::from(1), range.end()),
|
||||||
}
|
new_name.strip_prefix('\'').unwrap_or(new_name).to_owned(),
|
||||||
_ => new_name.into(),
|
),
|
||||||
|
_ => (range, new_name.to_owned()),
|
||||||
};
|
};
|
||||||
|
|
||||||
edit.replace(range, new_name);
|
edit.replace(range, new_name);
|
||||||
}
|
}
|
||||||
Ok((file_id, edit.finish()))
|
Ok((file_id, edit.finish()))
|
||||||
|
|
Loading…
Reference in a new issue