Skip to content

Commit

Permalink
extend inEnv:math to detect math better
Browse files Browse the repository at this point in the history
recognizes symbol delimiter math envs
  • Loading branch information
sunderme committed Jan 11, 2025
1 parent ac0f429 commit 673f77b
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/latexeditorview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ bool DefaultInputBinding::runMacros(QKeyEvent *event, QEditor *editor)
if(env.isEmpty()){
doc->getEnv(editor->cursor().lineNumber(),env);
}

// use topEnv as trigger env
const QStringList ignoreEnv = {"document","normal"};
if(!env.isEmpty() && !ignoreEnv.contains(env.top().name)){
Expand All @@ -153,7 +154,27 @@ bool DefaultInputBinding::runMacros(QKeyEvent *event, QEditor *editor)
continue;
}
} else {
continue;
// special treatment for math env as that be be toggled with special symbols
if(envTriggers.contains("math")){
QVector<QParenthesis>parenthesis=line.parentheses();
bool inMath=false;
for(int i=0;i<parenthesis.size();++i){
QParenthesis &p=parenthesis[i];
if(p.id==61){
if(p.offset<column){
inMath=(p.role & QParenthesis::Open)>0;
}
if(p.offset>=column){
break;
}
}
}
if(!inMath){
continue; // skip further trigger checks
}
}else{
continue;
}
}
}
const QRegularExpression &r = m.triggerRegex;
Expand Down

0 comments on commit 673f77b

Please sign in to comment.