diff --git a/crates/references/src/command.rs b/crates/references/src/command.rs index f4504641f..cf5849a13 100644 --- a/crates/references/src/command.rs +++ b/crates/references/src/command.rs @@ -32,7 +32,9 @@ pub(super) fn find_all(context: &mut ReferenceContext) -> Option<()> { .collect(); for command in &data.semantics.commands { - if command.text == token.text()[1..] { + let command_text = command.text.trim_end_matches('*'); + let token_text = token.text()[1..].trim_end_matches('*'); + if command_text == token_text { let kind = if defs.contains(command) { ReferenceKind::Definition } else { diff --git a/crates/references/src/tests.rs b/crates/references/src/tests.rs index 845282afb..713148069 100644 --- a/crates/references/src/tests.rs +++ b/crates/references/src/tests.rs @@ -260,3 +260,43 @@ fn test_new_command_definition_include_decl() { true, ); } + +#[test] +fn test_new_command_definition_starred() { + check( + r#" +%! main.tex +\foo + ^^^ +\foo* + | + ^^^^ + +\NewDocumentCommand{\foo}{s m}{% + \IfBooleanTF{#1}{\textbf{#2}}{#2}% +} +"#, + false, + ); +} + +#[test] +fn test_new_command_definition_starred_include_decl() { + check( + r#" +%! main.tex +\foo + ^^^ +\foo* + | + ^^^^ + +\NewDocumentCommand{\foo}{s m}{% + ^^^ + \IfBooleanTF{#1}{\textbf{#2}}{#2}% +} + +"#, + true, + ); +}