mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
Remove unused cursor positions
This commit is contained in:
parent
f83785a94a
commit
04a8daaa33
1 changed files with 7 additions and 13 deletions
|
@ -111,7 +111,7 @@ fn on_dot_typed(file: &SourceFile, offset: TextSize) -> Option<SingleFileChange>
|
|||
Some(SingleFileChange {
|
||||
label: "reindent dot".to_string(),
|
||||
edit: TextEdit::replace(TextRange::new(offset - current_indent_len, offset), target_indent),
|
||||
cursor_position: Some(offset + target_indent_len - current_indent_len + TextSize::of('.')),
|
||||
cursor_position: None,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -130,7 +130,7 @@ fn on_arrow_typed(file: &SourceFile, offset: TextSize) -> Option<SingleFileChang
|
|||
Some(SingleFileChange {
|
||||
label: "add space after return type".to_string(),
|
||||
edit: TextEdit::insert(after_arrow, " ".to_string()),
|
||||
cursor_position: Some(after_arrow),
|
||||
cursor_position: None,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -140,7 +140,7 @@ mod tests {
|
|||
|
||||
use super::*;
|
||||
|
||||
fn do_type_char(char_typed: char, before: &str) -> Option<(String, SingleFileChange)> {
|
||||
fn do_type_char(char_typed: char, before: &str) -> Option<String> {
|
||||
let (offset, before) = extract_offset(before);
|
||||
let edit = TextEdit::insert(offset, char_typed.to_string());
|
||||
let mut before = before.to_string();
|
||||
|
@ -148,21 +148,15 @@ mod tests {
|
|||
let parse = SourceFile::parse(&before);
|
||||
on_char_typed_inner(&parse.tree(), offset, char_typed).map(|it| {
|
||||
it.edit.apply(&mut before);
|
||||
(before.to_string(), it)
|
||||
before.to_string()
|
||||
})
|
||||
}
|
||||
|
||||
fn type_char(char_typed: char, before: &str, after: &str) {
|
||||
let (actual, file_change) = do_type_char(char_typed, before)
|
||||
let actual = do_type_char(char_typed, before)
|
||||
.unwrap_or_else(|| panic!("typing `{}` did nothing", char_typed));
|
||||
|
||||
if after.contains("<|>") {
|
||||
let (offset, after) = extract_offset(after);
|
||||
assert_eq_text!(&after, &actual);
|
||||
assert_eq!(file_change.cursor_position, Some(offset))
|
||||
} else {
|
||||
assert_eq_text!(after, &actual);
|
||||
}
|
||||
assert_eq_text!(after, &actual);
|
||||
}
|
||||
|
||||
fn type_char_noop(char_typed: char, before: &str) {
|
||||
|
@ -350,6 +344,6 @@ fn foo() {
|
|||
|
||||
#[test]
|
||||
fn adds_space_after_return_type() {
|
||||
type_char('>', "fn foo() -<|>{ 92 }", "fn foo() -><|> { 92 }")
|
||||
type_char('>', "fn foo() -<|>{ 92 }", "fn foo() -> { 92 }")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue