Skip to content

Commit

Permalink
handle specialDef better at initial document read
Browse files Browse the repository at this point in the history
  • Loading branch information
sunderme committed Nov 2, 2023
1 parent 3c8c7fd commit 0700fc7
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/latexdocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,9 +611,10 @@ void LatexDocument::interpretCommandArguments(QDocumentLineHandle *dlh, const in
data.completerNeedsUpdate = true;
QString definition = ltxCommands.specialDefCommands.value(cmd);
QString elem = tk.getText();
mUserCommandList.insert(dlh, UserCommandPair(QString(), definition + "%" + elem));
if (!data.removedUserCommands.removeAll(elem)) {
data.addedUserCommands << elem;
QString completeDefinition=definition + "%" + elem;
mUserCommandList.insert(dlh, UserCommandPair(QString(), completeDefinition));
if (!data.removedUserCommands.removeAll(completeDefinition)) {
data.addedUserCommands << completeDefinition;
}
}

Expand Down Expand Up @@ -1142,6 +1143,16 @@ void LatexDocument::handleRescanDocuments(HandledData changedCommands){
}
if(!changedCommands.addedUserCommands.isEmpty()){
lp->possibleCommands["user"].unite(ltxCommands.possibleCommands["user"]);
// handle specialDef commands
for(const QString &key: changedCommands.addedUserCommands){
if(key.startsWith("%")){
int i = key.indexOf('%', 1);
QString category = key.left(i);
QString elem = key.mid(i + 1);
lp->possibleCommands[category].insert(elem);
ltxCommands.possibleCommands[category].insert(elem);
}
}
}
}
synChecker.setLtxCommands(lp); // redundant here, updateCompletionfiles
Expand Down

0 comments on commit 0700fc7

Please sign in to comment.