[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [ktexteditor] src/vimode: Make SedReplaceHistory use the new generic Completion approach.
From: Simon St James <kdedevel () etotheipiplusone ! com>
Date: 2016-06-17 8:18:09
Message-ID: E1bDoyf-0002ZN-Ie () scm ! kde ! org
[Download RAW message or body]
Git commit 12ce80e637d8c2f969a778d8890a5298dca75f82 by Simon St James.
Committed on 17/06/2016 at 08:14.
Pushed by sstjames into branch 'master'.
Make SedReplaceHistory use the new generic Completion approach.
M +10 -9 src/vimode/emulatedcommandbar.cpp
M +1 -1 src/vimode/emulatedcommandbar.h
http://commits.kde.org/ktexteditor/12ce80e637d8c2f969a778d8890a5298dca75f82
diff --git a/src/vimode/emulatedcommandbar.cpp b/src/vimode/emulatedcommandbar.cpp
index 0959868..b56365f 100644
--- a/src/vimode/emulatedcommandbar.cpp
+++ b/src/vimode/emulatedcommandbar.cpp
@@ -661,14 +661,19 @@ EmulatedCommandBar::CompletionStartParams \
EmulatedCommandBar::activateSedFindHis return completionStartParams;
}
-void EmulatedCommandBar::activateSedReplaceHistoryCompletion()
+EmulatedCommandBar::CompletionStartParams \
EmulatedCommandBar::activateSedReplaceHistoryCompletion() {
+ CompletionStartParams completionStartParams;
+ completionStartParams.shouldStart = false;
if (!m_viInputModeManager->globalState()->replaceHistory()->isEmpty()) {
+ completionStartParams.completions = \
reversed(m_viInputModeManager->globalState()->replaceHistory()->items()); + \
completionStartParams.shouldStart = true; + \
completionStartParams.completionTransform = [this] (const QString& completion) -> \
QString { return withCaseSensitivityMarkersStripped(withSedDelimiterEscaped(completion)); \
}; + ParsedSedExpression parsedSedExpression = parseAsSedExpression();
+ completionStartParams.wordStartPos = parsedSedExpression.replaceBeginPos;
m_currentCompletionType = SedReplaceHistory;
- m_completionModel->setStringList(reversed(m_viInputModeManager->globalState()->replaceHistory()->items()));
- m_completer->setCompletionPrefix(sedReplaceTerm());
- m_completer->complete();
}
+ return completionStartParams;
}
void EmulatedCommandBar::deactivateCompletion()
@@ -722,10 +727,6 @@ void EmulatedCommandBar::currentCompletionChanged()
const int newCursorPosition = m_edit->cursorPosition() + \
(newCompletion.length() - commandBeforeCursor().length()); \
replaceCommandBeforeCursorWith(newCompletion); \
m_edit->setCursorPosition(newCursorPosition);
- } else if (m_currentCompletionType == SedReplaceHistory) {
- m_edit->setText(withSedReplaceTermReplacedWith(withSedDelimiterEscaped(newCompletion)));
- ParsedSedExpression parsedSedExpression = parseAsSedExpression();
- m_edit->setCursorPosition(parsedSedExpression.replaceEndPos + 1);
} else {
QString transformedCompletion = newCompletion;
if (m_currentCompletionStartParams.completionTransform)
@@ -885,7 +886,7 @@ bool EmulatedCommandBar::handleKeyPress(const QKeyEvent \
*keyEvent) if (isCursorInFindTermOfSed()) {
completionStartParams = activateSedFindHistoryCompletion();
} else if (isCursorInReplaceTermOfSed()) {
- activateSedReplaceHistoryCompletion();
+ completionStartParams = activateSedReplaceHistoryCompletion();
} else {
activateCommandHistoryCompletion();
}
diff --git a/src/vimode/emulatedcommandbar.h b/src/vimode/emulatedcommandbar.h
index be1ca69..6cf5106 100644
--- a/src/vimode/emulatedcommandbar.h
+++ b/src/vimode/emulatedcommandbar.h
@@ -176,7 +176,7 @@ private:
void activateCommandCompletion();
void activateCommandHistoryCompletion();
CompletionStartParams activateSedFindHistoryCompletion();
- void activateSedReplaceHistoryCompletion();
+ CompletionStartParams activateSedReplaceHistoryCompletion();
void deactivateCompletion();
void abortCompletionAndResetToPreCompletion();
void setCompletionIndex(int index);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic