From 5299a35e3dc484ea2e7d42cfeed89aee806425d3 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 28 Dec 2018 20:33:39 +0300 Subject: extend selection works with macros --- crates/ra_analysis/src/macros.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'crates/ra_analysis/src/macros.rs') diff --git a/crates/ra_analysis/src/macros.rs b/crates/ra_analysis/src/macros.rs index c0dd49dc8..b9feb7fad 100644 --- a/crates/ra_analysis/src/macros.rs +++ b/crates/ra_analysis/src/macros.rs @@ -61,4 +61,15 @@ impl MacroExpansion { } None } + pub(crate) fn map_range_forward(&self, src_range: TextRange) -> Option { + for (s_range, t_range) in self.ranges_map.iter() { + if src_range.is_subrange(&s_range) { + let src_at_zero_range = src_range - src_range.start(); + let src_range_offset = src_range.start() - s_range.start(); + let src_range = src_at_zero_range + src_range_offset + t_range.start(); + return Some(src_range); + } + } + None + } } -- cgit v1.2.3