Skip to content

Commit 8a3ad0a

Browse files
committed
fix #4207
1 parent 0040fcd commit 8a3ad0a

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

src/latexparser/latexparsing.cpp

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,13 @@ bool latexDetermineContexts2(QDocumentLineHandle *dlh, TokenStack &stack, Comman
451451
if(lastComma>0){
452452
// -> val
453453
tk.subtype=Token::keyVal_val;
454-
QString cmd=lexed[lastComma].optionalCommandName;
455-
QString key=line.mid(lexed[lastComma].start, lexed[lastComma].length);
456-
tk.optionalCommandName=cmd+"/"+key;
454+
if(lastComma>=1e6){
455+
tk.optionalCommandName=keyVal_keyString;
456+
}else{
457+
QString cmd=lexed[lastComma].optionalCommandName;
458+
QString key=line.mid(lexed[lastComma].start, lexed[lastComma].length);
459+
tk.optionalCommandName=cmd+"/"+key;
460+
}
457461
}else{
458462
tk.subtype=Token::keyVal_key; // not sure if that is a real scenario
459463
}
@@ -562,9 +566,13 @@ bool latexDetermineContexts2(QDocumentLineHandle *dlh, TokenStack &stack, Comman
562566
if(lastComma>0){
563567
// -> val
564568
tk.subtype=Token::keyVal_val;
565-
QString cmd=lexed[lastComma].optionalCommandName;
566-
QString key=line.mid(lexed[lastComma].start, lexed[lastComma].length);
567-
tk.optionalCommandName=cmd+"/"+key;
569+
if(lastComma>=1e6){
570+
tk.optionalCommandName=keyVal_keyString;
571+
}else{
572+
QString cmd=lexed[lastComma].optionalCommandName;
573+
QString key=line.mid(lexed[lastComma].start, lexed[lastComma].length);
574+
tk.optionalCommandName=cmd+"/"+key;
575+
}
568576
}else{
569577
tk.subtype=Token::keyVal_key; // not sure if that is a real scenario
570578
}
@@ -744,7 +752,9 @@ bool latexDetermineContexts2(QDocumentLineHandle *dlh, TokenStack &stack, Comman
744752
lexed << tk;
745753
lastComma = lexed.length() - 1;
746754
} else {
747-
lexed[lastComma].length = tk.start + tk.length - lexed[lastComma].start;
755+
if(lastComma<1e6){
756+
lexed[lastComma].length = tk.start + tk.length - lexed[lastComma].start;
757+
}
748758
}
749759
continue;
750760
}
@@ -803,8 +813,10 @@ bool latexDetermineContexts2(QDocumentLineHandle *dlh, TokenStack &stack, Comman
803813
lastComma = lexed.length() - 1;
804814
} else {
805815
if (lastEqual <= -1e6) {
806-
lexed[lastComma].length = tk.start + tk.length - lexed[lastComma].start;
807-
keyName= line.mid(tk.start, lexed[lastComma].length);
816+
if(lastComma<1e6){
817+
lexed[lastComma].length = tk.start + tk.length - lexed[lastComma].start;
818+
keyName= line.mid(tk.start, lexed[lastComma].length);
819+
}
808820
} else {
809821
tk.level = level;
810822
tk.subtype = Token::keyVal_val;

src/tests/syntaxcheck_t.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,10 @@ void SyntaxCheckTest::checkkeyval_data(){
276276
<<"\\usepackage{tcolorbox} \\newtcbox[auto counter]{cmd}{after kip balanced=glue}"<<true;
277277
QTest::newRow("tcolorbox, different values in 2 args, error in 1st")
278278
<<"\\usepackage{tcolorbox} \\newtcbox[aut counter]{cmd}{after skip balanced=glue}"<<true;
279+
QTest::newRow("tcolorbox, multiline")
280+
<<"\\usepackage{tcolorbox} \\begin{tcolorbox}[title=\n{test}]\n\\end{tcolorbox}"<<false;
281+
QTest::newRow("tcolorbox, different values in 2 args, error in 1st")
282+
<<"\\usepackage{tcolorbox} \\newtcbox[aut counter]{cmd}{after skip balanced=glue}"<<true;
279283
QTest::newRow("thmtools,multi word keyval")
280284
<<"\\usepackage{thm-kv} \\declaretheorem[numbered=unless unique]{test}"<<false;
281285
QTest::newRow("thmtools,multi word keyval,fault in first")

0 commit comments

Comments
 (0)