From 64a49589e74447da668bd5acab8375206a10253f Mon Sep 17 00:00:00 2001 From: David Lattimore Date: Sat, 27 Jun 2020 20:34:21 +1000 Subject: Fix handling of whitespace when applying SSR within macro expansions. I originally did replacement by passing in the full file text. Then as some point I thought I could do without it. Turns out calling .text() on a node coming from a macro expansion isn't a great idea, especially when you then try and use ranges from the original source to cut that text. The test I added here actually panics without the rest of this change (sorry I didn't notice sooner). --- crates/ra_ssr/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'crates/ra_ssr/src/lib.rs') diff --git a/crates/ra_ssr/src/lib.rs b/crates/ra_ssr/src/lib.rs index 8f149e3db..e148f4564 100644 --- a/crates/ra_ssr/src/lib.rs +++ b/crates/ra_ssr/src/lib.rs @@ -69,7 +69,8 @@ impl<'db> MatchFinder<'db> { if matches.matches.is_empty() { None } else { - Some(replacing::matches_to_edit(&matches)) + use ra_db::SourceDatabaseExt; + Some(replacing::matches_to_edit(&matches, &self.sema.db.file_text(file_id))) } } -- cgit v1.2.3