mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-28 14:03:35 +00:00
exclude '
This commit is contained in:
parent
5f1796f837
commit
5d013a79d6
1 changed files with 9 additions and 3 deletions
|
@ -13,7 +13,7 @@ use ide_db::{
|
|||
};
|
||||
use itertools::Itertools;
|
||||
use stdx::{always, never};
|
||||
use syntax::{ast, AstNode, SyntaxNode};
|
||||
use syntax::{ast, AstNode, SyntaxNode, TextRange, TextSize};
|
||||
|
||||
use text_edit::TextEdit;
|
||||
|
||||
|
@ -48,7 +48,13 @@ pub(crate) fn prepare_rename(
|
|||
frange.range.contains_inclusive(position.offset)
|
||||
&& frange.file_id == position.file_id
|
||||
);
|
||||
Ok(frange.range)
|
||||
|
||||
Ok(match name_like {
|
||||
ast::NameLike::Lifetime(_) => {
|
||||
TextRange::new(frange.range.start() + TextSize::from(1), frange.range.end())
|
||||
}
|
||||
_ => frange.range,
|
||||
})
|
||||
})
|
||||
.reduce(|acc, cur| match (acc, cur) {
|
||||
// ensure all ranges are the same
|
||||
|
@ -407,7 +413,7 @@ mod tests {
|
|||
#[test]
|
||||
fn test_prepare_rename_namelikes() {
|
||||
check_prepare(r"fn name$0<'lifetime>() {}", expect![[r#"3..7: name"#]]);
|
||||
check_prepare(r"fn name<'lifetime$0>() {}", expect![[r#"8..17: 'lifetime"#]]);
|
||||
check_prepare(r"fn name<'lifetime$0>() {}", expect![[r#"9..17: lifetime"#]]);
|
||||
check_prepare(r"fn name<'lifetime>() { name$0(); }", expect![[r#"23..27: name"#]]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue