Commit 57367f70 authored by Waqar Ahmed's avatar Waqar Ahmed
Browse files

More quickopen performance improvement

parent f1964ef4
...@@ -284,7 +284,11 @@ bool KateQuickOpen::eventFilter(QObject *obj, QEvent *event) ...@@ -284,7 +284,11 @@ bool KateQuickOpen::eventFilter(QObject *obj, QEvent *event)
if (keyEvent->key() == Qt::Key_Escape) { if (keyEvent->key() == Qt::Key_Escape) {
m_mainWindow->slotWindowActivated(); m_mainWindow->slotWindowActivated();
m_inputLine->clear(); {
m_inputLine->blockSignals(true);
m_inputLine->clear();
m_inputLine->blockSignals(false);
}
keyEvent->accept(); keyEvent->accept();
hide(); hide();
return true; return true;
...@@ -302,7 +306,11 @@ bool KateQuickOpen::eventFilter(QObject *obj, QEvent *event) ...@@ -302,7 +306,11 @@ bool KateQuickOpen::eventFilter(QObject *obj, QEvent *event)
// hide on focus out, if neither input field nor list have focus! // hide on focus out, if neither input field nor list have focus!
else if (event->type() == QEvent::FocusOut && !(m_inputLine->hasFocus() || m_listView->hasFocus())) { else if (event->type() == QEvent::FocusOut && !(m_inputLine->hasFocus() || m_listView->hasFocus())) {
m_mainWindow->slotWindowActivated(); m_mainWindow->slotWindowActivated();
m_inputLine->clear(); {
m_inputLine->blockSignals(true);
m_inputLine->clear();
m_inputLine->blockSignals(false);
}
hide(); hide();
return true; return true;
} }
......
...@@ -85,6 +85,25 @@ static bool fuzzy_match_simple(const QStringView pattern, const QStringView str) ...@@ -85,6 +85,25 @@ static bool fuzzy_match_simple(const QStringView pattern, const QStringView str)
static bool fuzzy_match(const QStringView pattern, const QStringView str, int &outScore) static bool fuzzy_match(const QStringView pattern, const QStringView str, int &outScore)
{ {
// simple substring matching to flush out non-matching stuff
auto patternIt = pattern.cbegin();
bool lower = patternIt->isLower();
QChar cUp = lower ? patternIt->toUpper() : *patternIt;
QChar cLow = lower ? *patternIt : patternIt->toLower();
for (auto strIt = str.cbegin(); strIt != str.cend() && patternIt != pattern.cend(); ++strIt) {
if (*strIt == cLow || *strIt == cUp) {
++patternIt;
lower = patternIt->isLower();
cUp = lower ? patternIt->toUpper() : *patternIt;
cLow = lower ? *patternIt : patternIt->toLower();
}
}
if (patternIt != pattern.cend()) {
outScore = 0;
return false;
}
uint8_t matches[256]; uint8_t matches[256];
return fuzzy_match(pattern, str, outScore, matches); return fuzzy_match(pattern, str, outScore, matches);
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment