[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [ktexteditor] src/vimode: Experimental: begin working towards making completion deduce more things f
From: Simon St James <kdedevel () etotheipiplusone ! com>
Date: 2016-06-17 8:18:09
Message-ID: E1bDoyf-0002ZN-GN () scm ! kde ! org
[Download RAW message or body]
Git commit d027227e6a606c28fe446227c0fb9aff216df6f2 by Simon St James.
Committed on 17/06/2016 at 08:14.
Pushed by sstjames into branch 'master'.
Experimental: begin working towards making completion deduce more things for itself \
(e.g. the current completionPrefix) and move towards creating an API where, if we \
request a completion session, the current ActiveMode will return a \
CompletionStartParams, further decoupling EmulatedCommandBar's keypress handler from \
the internal details of the ActiveModes.
M +17 -1 src/vimode/emulatedcommandbar.cpp
M +6 -0 src/vimode/emulatedcommandbar.h
http://commits.kde.org/ktexteditor/d027227e6a606c28fe446227c0fb9aff216df6f2
diff --git a/src/vimode/emulatedcommandbar.cpp b/src/vimode/emulatedcommandbar.cpp
index 3a0be08..547fbb5 100644
--- a/src/vimode/emulatedcommandbar.cpp
+++ b/src/vimode/emulatedcommandbar.cpp
@@ -871,9 +871,18 @@ bool EmulatedCommandBar::handleKeyPress(const QKeyEvent \
*keyEvent) }
if ((keyEvent->modifiers() == Qt::ControlModifier && keyEvent->key() == \
Qt::Key_P) || keyEvent->key() == Qt::Key_Down) { if \
(!m_completer->popup()->isVisible()) { + CompletionStartParams \
completionStartParams; + completionStartParams.shouldStart = false;
if (m_mode == Command) {
if (isCursorInFindTermOfSed()) {
- activateSedFindHistoryCompletion();
+ //activateSedFindHistoryCompletion();
+ if \
(!m_viInputModeManager->globalState()->searchHistory()->isEmpty()) { + \
completionStartParams.completions = \
reversed(m_viInputModeManager->globalState()->searchHistory()->items()); + \
completionStartParams.shouldStart = true; + \
ParsedSedExpression parsedSedExpression = parseAsSedExpression(); + \
completionStartParams.wordStartPos = parsedSedExpression.findBeginPos; + \
m_currentCompletionType = SedFindHistory; + }
} else if (isCursorInReplaceTermOfSed()) {
activateSedReplaceHistoryCompletion();
} else {
@@ -882,6 +891,13 @@ bool EmulatedCommandBar::handleKeyPress(const QKeyEvent \
*keyEvent) } else {
activateSearchHistoryCompletion();
}
+ 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(); + }
if (m_currentCompletionType != None) {
setCompletionIndex(0);
}
diff --git a/src/vimode/emulatedcommandbar.h b/src/vimode/emulatedcommandbar.h
index 23a9d29..04a95b7 100644
--- a/src/vimode/emulatedcommandbar.h
+++ b/src/vimode/emulatedcommandbar.h
@@ -141,6 +141,12 @@ private:
bool m_completionActive;
QString m_textToRevertToIfCompletionAborted;
int m_cursorPosToRevertToIfCompletionAborted;
+ struct CompletionStartParams
+ {
+ bool shouldStart;
+ int wordStartPos;
+ QStringList completions;
+ };
KTextEditor::Attribute::Ptr m_highlightMatchAttribute;
KTextEditor::MovingRange *m_highlightedMatch;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic