Skip to content

Commit

Permalink
Fix infinite loop if arg. protoypes don't match
Browse files Browse the repository at this point in the history
  • Loading branch information
me-johnomar authored and valentjn committed Nov 15, 2020
1 parent 7342942 commit 72590d4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ public LatexAnnotatedTextBuilder addCode(String code) {
for (LatexCommandSignature latexCommandSignature : possibleCommandSignatures) {
String curMatch = latexCommandSignature.matchFromPosition(code, this.pos);

if (curMatch.length() >= match.length()) {
if (!curMatch.isEmpty() && (curMatch.length() >= match.length())) {
match = curMatch;
matchingCommand = latexCommandSignature;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ public void testTextMode() {
"This is a test: \\colorbox{abc}{def}.\n",
"This is a test: Dummy0def. ",
(new Settings()).withLatexCommands(Collections.singletonMap("\\colorbox{}", "dummy")));
assertPlainText(
"\\setcounter{a}[b]{c} This is an test.\n",
"a[b]c This is an test. ");

{
AnnotatedText annotatedText = buildAnnotatedText("\\cite{Kubota}*{Theorem 3.7}\n");
Expand Down

0 comments on commit 72590d4

Please sign in to comment.