[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [ktexteditor] src/vimode: Our only uses of commandBeforeCursor() where essentially to compute comman
From:       Simon St James <kdedevel () etotheipiplusone ! com>
Date:       2016-06-17 8:18:10
Message-ID: E1bDoyg-0002ZN-15 () scm ! kde ! org
[Download RAW message or body]

Git commit 56b41140c35f15a60d5b695cdcbba6651b17b2e7 by Simon St James.
Committed on 17/06/2016 at 08:14.
Pushed by sstjames into branch 'master'.

Our only uses of commandBeforeCursor() where essentially to compute \
commandBeforeCursorBegin(), so just use the latter directly and delete \
commandBeforeCursor().

M  +2    -14   src/vimode/emulatedcommandbar.cpp
M  +0    -1    src/vimode/emulatedcommandbar.h

http://commits.kde.org/ktexteditor/56b41140c35f15a60d5b695cdcbba6651b17b2e7

diff --git a/src/vimode/emulatedcommandbar.cpp b/src/vimode/emulatedcommandbar.cpp
index c9785c8..fd88520 100644
--- a/src/vimode/emulatedcommandbar.cpp
+++ b/src/vimode/emulatedcommandbar.cpp
@@ -1159,7 +1159,7 @@ void EmulatedCommandBar::CommandMode::editTextChanged ( const \
                QString& newText,
     if (!withoutRangeExpression().isEmpty() && \
                !isNextTextChangeDueToCompletionChange) {
         // ... However, command completion mode should not be automatically invoked \
                if this is not the current leading
         // word in the text edit (it gets annoying if completion pops up after \
                ":s/se" etc).
-        const bool commandBeforeCursorIsLeading = (m_edit->cursorPosition() - \
commandBeforeCursor().length() == rangeExpression().length()); +        const bool \
commandBeforeCursorIsLeading = (commandBeforeCursorBegin() == \
rangeExpression().length());  if (commandBeforeCursorIsLeading) {
             CompletionStartParams completionStartParams = \
activateCommandCompletion();  startCompletion(completionStartParams);
@@ -1372,18 +1372,6 @@ bool \
EmulatedCommandBar::CommandMode::isCursorInReplaceTermOfSed()  return \
parsedSedExpression.parsedSuccessfully && m_edit->cursorPosition() >= \
parsedSedExpression.replaceBeginPos && m_edit->cursorPosition() <= \
parsedSedExpression.replaceEndPos + 1;  }
 
-QString EmulatedCommandBar::CommandMode::commandBeforeCursor()
-{
-    const QString textWithoutRangeExpression = withoutRangeExpression();
-    const int cursorPositionWithoutRangeExpression = m_edit->cursorPosition() - \
                rangeExpression().length();
-    int commandBeforeCursorBegin = cursorPositionWithoutRangeExpression - 1;
-    while (commandBeforeCursorBegin >= 0 && \
(textWithoutRangeExpression[commandBeforeCursorBegin].isLetterOrNumber() || \
textWithoutRangeExpression[commandBeforeCursorBegin] == QLatin1Char('_') || \
                textWithoutRangeExpression[commandBeforeCursorBegin] == \
                QLatin1Char('-'))) {
-        commandBeforeCursorBegin--;
-    }
-    commandBeforeCursorBegin++;
-    return textWithoutRangeExpression.mid(commandBeforeCursorBegin, \
                cursorPositionWithoutRangeExpression - commandBeforeCursorBegin);
-}
-
 int EmulatedCommandBar::CommandMode::commandBeforeCursorBegin()
 {
     const QString textWithoutRangeExpression = withoutRangeExpression();
@@ -1399,7 +1387,7 @@ int EmulatedCommandBar::CommandMode::commandBeforeCursorBegin()
 
 void EmulatedCommandBar::CommandMode::replaceCommandBeforeCursorWith ( const \
QString& newCommand )  {
-    const QString newText = m_edit->text().left(m_edit->cursorPosition() - \
commandBeforeCursor().length()) + +    const QString newText = \
m_edit->text().left(commandBeforeCursorBegin()) +  newCommand +
                             m_edit->text().mid(m_edit->cursorPosition());
     m_edit->setText(newText);
diff --git a/src/vimode/emulatedcommandbar.h b/src/vimode/emulatedcommandbar.h
index 01e7188..a15693c 100644
--- a/src/vimode/emulatedcommandbar.h
+++ b/src/vimode/emulatedcommandbar.h
@@ -218,7 +218,6 @@ private:
         * the range over which the command should be run e.g. '<,'>.  @see \
                CommandRangeExpressionParser
         */
         CommandMode::ParsedSedExpression parseAsSedExpression(); // TODO - make \
                private
-        QString commandBeforeCursor();
         int commandBeforeCursorBegin();
         void replaceCommandBeforeCursorWith(const QString &newCommand);
         CompletionStartParams activateCommandCompletion();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic