aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-06-02 20:39:53 +0100
committerLukas Wirth <[email protected]>2021-06-02 20:42:49 +0100
commit841feef79ee9349a9f82e4b642f22aa0f7abcae5 (patch)
treefbc0c50dac2917061b0b3c8b9e79b321d23dea14
parent5be653d426e3e3fd253f41f85e7d280a82037da9 (diff)
Allow expand-macro to be invoked anywhere inside a macro call
-rw-r--r--crates/ide/src/expand_macro.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/crates/ide/src/expand_macro.rs b/crates/ide/src/expand_macro.rs
index eebae5ebe..e0d01fa96 100644
--- a/crates/ide/src/expand_macro.rs
+++ b/crates/ide/src/expand_macro.rs
@@ -28,8 +28,8 @@ pub struct ExpandedMacro {
28pub(crate) fn expand_macro(db: &RootDatabase, position: FilePosition) -> Option<ExpandedMacro> { 28pub(crate) fn expand_macro(db: &RootDatabase, position: FilePosition) -> Option<ExpandedMacro> {
29 let sema = Semantics::new(db); 29 let sema = Semantics::new(db);
30 let file = sema.parse(position.file_id); 30 let file = sema.parse(position.file_id);
31 let name_ref = find_node_at_offset::<ast::NameRef>(file.syntax(), position.offset)?; 31 let mac = find_node_at_offset::<ast::MacroCall>(file.syntax(), position.offset)?;
32 let mac = name_ref.syntax().ancestors().find_map(ast::MacroCall::cast)?; 32 let name = mac.path()?.segment()?.name_ref()?;
33 33
34 let expanded = expand_macro_recur(&sema, &mac)?; 34 let expanded = expand_macro_recur(&sema, &mac)?;
35 35
@@ -37,7 +37,7 @@ pub(crate) fn expand_macro(db: &RootDatabase, position: FilePosition) -> Option<
37 // macro expansion may lose all white space information 37 // macro expansion may lose all white space information
38 // But we hope someday we can use ra_fmt for that 38 // But we hope someday we can use ra_fmt for that
39 let expansion = insert_whitespaces(expanded); 39 let expansion = insert_whitespaces(expanded);
40 Some(ExpandedMacro { name: name_ref.text().to_string(), expansion }) 40 Some(ExpandedMacro { name: name.to_string(), expansion })
41} 41}
42 42
43fn expand_macro_recur( 43fn expand_macro_recur(