Skip to content

Commit

Permalink
Support starred variants in "Go to References" (#1235)
Browse files Browse the repository at this point in the history
Signed-off-by: Jonas Dujava <[email protected]>
  • Loading branch information
jdujava authored Oct 9, 2024
1 parent 79c1c06 commit c9ee5b1
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/references/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
40 changes: 40 additions & 0 deletions crates/references/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
);
}

0 comments on commit c9ee5b1

Please sign in to comment.