simplify auto-completion
This commit is contained in:
@ -391,29 +391,9 @@ void CodeEditor::keyPressEvent(QKeyEvent *event)
|
|||||||
// pop up completion automatically after 3 characters
|
// pop up completion automatically after 3 characters
|
||||||
if (automatic_completion) {
|
if (automatic_completion) {
|
||||||
auto cursor = textCursor();
|
auto cursor = textCursor();
|
||||||
auto line = cursor.block().text().trimmed();
|
cursor.select(QTextCursor::WordUnderCursor);
|
||||||
if (!line.isEmpty()) {
|
auto word = cursor.selectedText().trimmed();
|
||||||
auto words = split_line(line.toStdString());
|
if (word.length() > 2) runCompletion();
|
||||||
cursor.select(QTextCursor::WordUnderCursor);
|
|
||||||
auto word = cursor.selectedText().trimmed();
|
|
||||||
auto popup = command_comp->popup();
|
|
||||||
// we're on the first word in a line -> complete on commands
|
|
||||||
if (words[0] == word.toStdString()) {
|
|
||||||
if (word.length() > 2)
|
|
||||||
runCompletion();
|
|
||||||
else if (popup->isVisible())
|
|
||||||
popup->hide();
|
|
||||||
} else if (words[0] == "fix") {
|
|
||||||
if (words.size() > 2) { // fix style is 3rd word
|
|
||||||
if (word.length() > 2)
|
|
||||||
runCompletion();
|
|
||||||
else if (popup->isVisible())
|
|
||||||
popup->hide();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (popup->isVisible()) popup->hide();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user