Skip to content

Commit

Permalink
generalize env context for completion
Browse files Browse the repository at this point in the history
  • Loading branch information
sunderme committed Dec 21, 2024
1 parent 54143c9 commit 3b9ebd2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/latexeditorview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,10 @@ bool DefaultInputBinding::keyPressEvent(QKeyEvent *event, QEditor *editor)
const LatexDocument *doc = qobject_cast<LatexDocument *>(editor->document());
StackEnvironment env;
doc->getEnv(editor->cursor().lineNumber(),env);
if(!env.isEmpty() && env.top().name=="%expl3"){
LatexEditorView::completer->setFilter("%expl3");
// use topEnv as completion filter for commands
const QStringList ignoreEnv = {"document","normal"};
if(!env.isEmpty() && !ignoreEnv.contains(env.top().name)){
LatexEditorView::completer->setFilter(env.top().name);
}

LatexCompleter::CompletionFlags flags= ctx==EnumsTokenType::width ? LatexCompleter::CF_FORCE_LENGTH : LatexCompleter::CompletionFlag(0) ;
Expand Down
9 changes: 9 additions & 0 deletions src/texstudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4873,6 +4873,15 @@ void Texstudio::normalCompletion()
return;
}
}
} else {
// use topEnv as completion filter for commands
if( type == Token::command && !env.isEmpty()){
// skip filter for normal or document
const QStringList ignoreEnv = {"document","normal"};
if(!ignoreEnv.contains(env.top().name)){
completer->setFilter(env.top().name);
}
}
}
}
switch (type) {
Expand Down

0 comments on commit 3b9ebd2

Please sign in to comment.