string new_input;
vector<string> const & comp = completions(input, new_input);
- if (comp.empty()) {
+ if (comp.empty() || comp.size() == 1) {
if (new_input != input)
edit_->setText(toqstr(new_input));
+ // If there is only one match, indicate this by adding a space
+ if (comp.size() == 1)
+ edit_->setText(edit_->text() + " ");
return;
}
else
listBox->addItem(toqstr(item));
}
+ // Select the first item
+ listBox->setCurrentItem(listBox->item(0));
listBox->resize(listBox->sizeHint());
if (prefixIs(act.first, prefix))
comp.push_back(act.first);
}
+ // now add all the other items that contain the prefix
+ for (auto const & act : lyxaction) {
+ if (!prefixIs(act.first, prefix) && contains(act.first, prefix))
+ comp.push_back(act.first);
+ }
if (comp.empty()) {
new_prefix = prefix;
if (comp.size() == 1) {
new_prefix = comp[0];
- return vector<string>();
+ return comp;
}
// find maximal available prefix
void GuiCommandEdit::keyPressEvent(QKeyEvent * e)
{
- switch (e->key()) {
- case Qt::Key_Escape:
- // emit signal
- escapePressed();
- break;
-
- case Qt::Key_Up:
- // emit signal
- upPressed();
- break;
-
- case Qt::Key_Down:
- // emit signal
- downPressed();
- break;
-
- default:
- QLineEdit::keyPressEvent(e);
- break;
+ if (e->modifiers() == Qt::NoModifier) {
+ switch (e->key()) {
+ case Qt::Key_Escape:
+ // emit signal
+ escapePressed();
+ return;
+
+ case Qt::Key_Up:
+ // emit signal
+ upPressed();
+ return;
+
+ case Qt::Key_Down:
+ // emit signal
+ downPressed();
+ return;
+
+ default:
+ // do nothing
+ break;
+ }
}
+ QLineEdit::keyPressEvent(e);
}