[UI] Keep focus in chat on Tab completion acceptance

This commit is contained in:
Lukas Brübach 2026-10-09 12:42:44 +02:00
parent b8b04f9a7a
commit 7b8d86f45a

View file

@ -88,8 +88,7 @@ void LineEditCompleter::keyPressEvent(QKeyEvent *event)
return;
}
if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter || event->key() == Qt::Key_Space ||
event->key() == Qt::Key_Tab) {
if (event->key() == Qt::Key_Return || event->key() == Qt::Key_Enter || event->key() == Qt::Key_Space) {
for (auto &info : completers) {
if (info.completer->popup()->isVisible()) {
event->ignore();
@ -109,6 +108,27 @@ void LineEditCompleter::keyPressEvent(QKeyEvent *event)
}
}
if (event->key() == Qt::Key_Tab) {
for (auto &info : completers) {
if (info.completer->popup()->isVisible()) {
event->ignore();
const QModelIndex currentIndex = info.completer->popup()->currentIndex();
QString completionText;
if (currentIndex.isValid()) {
completionText = currentIndex.data().toString();
} else {
completionText = info.completer->currentCompletion();
}
if (!completionText.isEmpty()) {
insertCompletion(info.completer, completionText);
}
hideCompleterPopups();
setFocus();
return;
}
}
}
LineEditUnfocusable::keyPressEvent(event);
QString textValue = text();