mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 11:31:15 +00:00
Merge #264
264: check for empty range when extending in comment r=matklad a=vemoo fix for #140 Co-authored-by: Bernardo <berublan@gmail.com>
This commit is contained in:
commit
5ad7547ce2
@ -54,7 +54,12 @@ fn extend_single_word_in_comment(leaf: SyntaxNodeRef, offset: TextUnit) -> Optio
|
||||
let from: TextUnit = (start_idx + 1).into();
|
||||
let to: TextUnit = (cursor_position + end_idx).into();
|
||||
|
||||
Some(TextRange::from_to(from, to) + leaf.range().start())
|
||||
let range = TextRange::from_to(from, to);
|
||||
if range.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(range + leaf.range().start())
|
||||
}
|
||||
}
|
||||
|
||||
fn extend_ws(root: SyntaxNodeRef, ws: SyntaxNodeRef, offset: TextUnit) -> TextRange {
|
||||
@ -181,6 +186,20 @@ fn bar(){}
|
||||
"#,
|
||||
&["// 1 + 1", "// fn foo() {\n// 1 + 1\n// }"],
|
||||
);
|
||||
|
||||
do_check(
|
||||
r#"
|
||||
// #[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
// pub enum Direction {
|
||||
// <|> Next,
|
||||
// Prev
|
||||
// }
|
||||
"#,
|
||||
&[
|
||||
"// Next,",
|
||||
"// #[derive(Debug, Clone, Copy, PartialEq, Eq)]\n// pub enum Direction {\n// Next,\n// Prev\n// }",
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
x
Reference in New Issue
Block a user