aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/typing
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src/typing')
-rw-r--r--crates/ra_ide/src/typing/on_enter.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/crates/ra_ide/src/typing/on_enter.rs b/crates/ra_ide/src/typing/on_enter.rs
index a40d8af9c..2faaa8ff0 100644
--- a/crates/ra_ide/src/typing/on_enter.rs
+++ b/crates/ra_ide/src/typing/on_enter.rs
@@ -75,23 +75,22 @@ fn node_indent(file: &SourceFile, token: &SyntaxToken) -> Option<SmolStr> {
75 75
76#[cfg(test)] 76#[cfg(test)]
77mod tests { 77mod tests {
78 use test_utils::{assert_eq_text, extract_offset}; 78 use test_utils::assert_eq_text;
79 79
80 use crate::mock_analysis::single_file; 80 use crate::mock_analysis::analysis_and_position;
81 81 use stdx::trim_indent;
82 use super::*;
83 82
84 fn apply_on_enter(before: &str) -> Option<String> { 83 fn apply_on_enter(before: &str) -> Option<String> {
85 let (offset, before) = extract_offset(before); 84 let (analysis, position) = analysis_and_position(&before);
86 let (analysis, file_id) = single_file(&before); 85 let result = analysis.on_enter(position).unwrap()?;
87 let result = analysis.on_enter(FilePosition { offset, file_id }).unwrap()?;
88 86
89 let mut actual = before.to_string(); 87 let mut actual = analysis.file_text(position.file_id).unwrap().to_string();
90 result.apply(&mut actual); 88 result.apply(&mut actual);
91 Some(actual) 89 Some(actual)
92 } 90 }
93 91
94 fn do_check(ra_fixture_before: &str, ra_fixture_after: &str) { 92 fn do_check(ra_fixture_before: &str, ra_fixture_after: &str) {
93 let ra_fixture_after = &trim_indent(ra_fixture_after);
95 let actual = apply_on_enter(ra_fixture_before).unwrap(); 94 let actual = apply_on_enter(ra_fixture_before).unwrap();
96 assert_eq_text!(ra_fixture_after, &actual); 95 assert_eq_text!(ra_fixture_after, &actual);
97 } 96 }