[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [ktexteditor] src/vimode: Make CommandHistory use the new Completion approach.
From: Simon St James <kdedevel () etotheipiplusone ! com>
Date: 2016-06-17 8:18:09
Message-ID: E1bDoyf-0002ZN-JW () scm ! kde ! org
[Download RAW message or body]
Git commit dec592a2a09640f24e26e49ca3684d4be6790e7b by Simon St James.
Committed on 17/06/2016 at 08:14.
Pushed by sstjames into branch 'master'.
Make CommandHistory use the new Completion approach.
M +18 -8 src/vimode/emulatedcommandbar.cpp
M +1 -1 src/vimode/emulatedcommandbar.h
http://commits.kde.org/ktexteditor/dec592a2a09640f24e26e49ca3684d4be6790e7b
diff --git a/src/vimode/emulatedcommandbar.cpp b/src/vimode/emulatedcommandbar.cpp
index b56365f..64d346f 100644
--- a/src/vimode/emulatedcommandbar.cpp
+++ b/src/vimode/emulatedcommandbar.cpp
@@ -638,12 +638,14 @@ void EmulatedCommandBar::activateCommandCompletion()
m_currentCompletionType = Commands;
}
-void EmulatedCommandBar::activateCommandHistoryCompletion()
+EmulatedCommandBar::CompletionStartParams \
EmulatedCommandBar::activateCommandHistoryCompletion() {
+ CompletionStartParams completionStartParams;
+ completionStartParams.completions = \
reversed(m_viInputModeManager->globalState()->commandHistory()->items()); \
m_currentCompletionType = CommandHistory;
- m_completionModel->setStringList(reversed(m_viInputModeManager->globalState()->commandHistory()->items()));
- updateCompletionPrefix();
- m_completer->complete();
+ completionStartParams.shouldStart = true;
+ completionStartParams.wordStartPos = 0;
+ return completionStartParams;
}
EmulatedCommandBar::CompletionStartParams \
EmulatedCommandBar::activateSedFindHistoryCompletion() @@ -721,8 +723,6 @@ void \
EmulatedCommandBar::currentCompletionChanged() \
replaceWordBeforeCursorWith(newCompletion); } else if (m_currentCompletionType == \
SearchHistory) { m_edit->setText(newCompletion);
- } else if (m_currentCompletionType == CommandHistory) {
- m_edit->setText(newCompletion);
} else if (m_currentCompletionType == Commands) {
const int newCursorPosition = m_edit->cursorPosition() + \
(newCompletion.length() - commandBeforeCursor().length()); \
replaceCommandBeforeCursorWith(newCompletion); @@ -888,7 +888,7 @@ bool \
EmulatedCommandBar::handleKeyPress(const QKeyEvent *keyEvent) } else if \
(isCursorInReplaceTermOfSed()) {
completionStartParams = activateSedReplaceHistoryCompletion();
} else {
- activateCommandHistoryCompletion();
+ completionStartParams = activateCommandHistoryCompletion();
}
} else {
activateSearchHistoryCompletion();
@@ -916,11 +916,21 @@ bool EmulatedCommandBar::handleKeyPress(const QKeyEvent \
*keyEvent) }
if ((keyEvent->modifiers() == Qt::ControlModifier && keyEvent->key() == \
Qt::Key_N) || keyEvent->key() == Qt::Key_Up) { if \
(!m_completer->popup()->isVisible()) { + CompletionStartParams \
completionStartParams; + completionStartParams.shouldStart = false;
if (m_mode == Command) {
- activateCommandHistoryCompletion();
+ completionStartParams = activateCommandHistoryCompletion();
} else {
activateSearchHistoryCompletion();
}
+ m_currentCompletionStartParams = completionStartParams;
+ if (completionStartParams.shouldStart)
+ {
+ m_completionModel->setStringList(completionStartParams.completions);
+ const QString completionPrefix = \
m_edit->text().mid(completionStartParams.wordStartPos, m_edit->cursorPosition() - \
completionStartParams.wordStartPos); + \
m_completer->setCompletionPrefix(completionPrefix); + \
m_completer->complete(); + }
setCompletionIndex(m_completer->completionCount() - 1);
} else {
// Ascend to previous row, wrapping around if necessary.
diff --git a/src/vimode/emulatedcommandbar.h b/src/vimode/emulatedcommandbar.h
index 6cf5106..ad615a0 100644
--- a/src/vimode/emulatedcommandbar.h
+++ b/src/vimode/emulatedcommandbar.h
@@ -174,7 +174,7 @@ private:
void activateSearchHistoryCompletion();
void activateWordFromDocumentCompletion();
void activateCommandCompletion();
- void activateCommandHistoryCompletion();
+ CompletionStartParams activateCommandHistoryCompletion();
CompletionStartParams activateSedFindHistoryCompletion();
CompletionStartParams activateSedReplaceHistoryCompletion();
void deactivateCompletion();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic