From 153849c01ba9aeb8c15c84dd34c6d1b9b47f3e46 Mon Sep 17 00:00:00 2001 From: Glutanimate Date: Wed, 30 Aug 2017 13:11:03 +0200 Subject: [PATCH] Apply first tag autosuggestion with Enter/Return --- aqt/tagedit.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/aqt/tagedit.py b/aqt/tagedit.py index e6a6d9c07..8603a90eb 100644 --- a/aqt/tagedit.py +++ b/aqt/tagedit.py @@ -37,9 +37,9 @@ class TagEdit(QLineEdit): def keyPressEvent(self, evt): if (evt.key() == Qt.Key_Tab and evt.modifiers() & Qt.ControlModifier): + # select next completion if not self.completer.popup().isVisible(): self.showCompleter() - # select next completion index = self.completer.currentIndex() self.completer.popup().setCurrentIndex(index) cur_row = index.row() @@ -47,6 +47,12 @@ class TagEdit(QLineEdit): self.completer.setCurrentRow(0) return if evt.key() in (Qt.Key_Enter, Qt.Key_Return): + # apply first completion if no suggestion selected + selected_row = self.completer.popup().currentIndex().row() + if selected_row == -1: + self.completer.setCurrentRow(0) + index = self.completer.currentIndex() + self.completer.popup().setCurrentIndex(index) self.hideCompleter() QWidget.keyPressEvent(self, evt) return