forked from qt-creator/qt-creator
Merge remote-tracking branch 'origin/2.8'
Conflicts: src/plugins/coreplugin/documentmanager.cpp Change-Id: I6dc025bc0f31eb694c8d9e2dd4ea5cc888ee8a94
This commit is contained in:
@@ -1440,8 +1440,11 @@ public:
|
||||
void init();
|
||||
void focus();
|
||||
|
||||
void enterFakeVim(); // Call before any FakeVim processing (import cursor position from editor)
|
||||
void leaveFakeVim(); // Call after any FakeVim processing (export cursor position to editor)
|
||||
// Call before any FakeVim processing (import cursor position from editor)
|
||||
void enterFakeVim();
|
||||
// Call after any FakeVim processing
|
||||
// (if needUpdate is true, export cursor position to editor and scroll)
|
||||
void leaveFakeVim(bool needUpdate = true);
|
||||
|
||||
EventResult handleKey(const Input &input);
|
||||
EventResult handleDefaultKey(const Input &input);
|
||||
@@ -2060,7 +2063,7 @@ void FakeVimHandler::Private::enterFakeVim()
|
||||
moveRight();
|
||||
}
|
||||
|
||||
void FakeVimHandler::Private::leaveFakeVim()
|
||||
void FakeVimHandler::Private::leaveFakeVim(bool needUpdate)
|
||||
{
|
||||
QTC_ASSERT(g.inFakeVim, qDebug() << "enterFakeVim() not called before leaveFakeVim()!");
|
||||
|
||||
@@ -2082,15 +2085,18 @@ void FakeVimHandler::Private::leaveFakeVim()
|
||||
|
||||
exportSelection();
|
||||
updateCursorShape();
|
||||
commitCursor();
|
||||
|
||||
// Move cursor line to middle of screen if it's not visible.
|
||||
const int line = cursorLine();
|
||||
if (line < firstVisibleLine() || line >= firstVisibleLine() + linesOnScreen())
|
||||
scrollToLine(qMax(0, line - linesOnScreen() / 2));
|
||||
else
|
||||
scrollToLine(firstVisibleLine());
|
||||
updateScrollOffset();
|
||||
if (needUpdate) {
|
||||
commitCursor();
|
||||
|
||||
// Move cursor line to middle of screen if it's not visible.
|
||||
const int line = cursorLine();
|
||||
if (line < firstVisibleLine() || line >= firstVisibleLine() + linesOnScreen())
|
||||
scrollToLine(qMax(0, line - linesOnScreen() / 2));
|
||||
else
|
||||
scrollToLine(firstVisibleLine());
|
||||
updateScrollOffset();
|
||||
}
|
||||
}
|
||||
|
||||
g.inFakeVim = false;
|
||||
@@ -2194,7 +2200,7 @@ EventResult FakeVimHandler::Private::handleEvent(QKeyEvent *ev)
|
||||
|
||||
enterFakeVim();
|
||||
EventResult result = handleKey(Input(key, mods, ev->text()));
|
||||
leaveFakeVim();
|
||||
leaveFakeVim(result == EventHandled);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -2603,8 +2609,8 @@ void FakeVimHandler::Private::timerEvent(QTimerEvent *ev)
|
||||
{
|
||||
if (ev->timerId() == g.inputTimer) {
|
||||
enterFakeVim();
|
||||
handleKey(Input());
|
||||
leaveFakeVim();
|
||||
EventResult result = handleKey(Input());
|
||||
leaveFakeVim(result == EventHandled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3673,7 +3679,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(const Input &input)
|
||||
// if a key which produces text was pressed, don't mark it as unhandled
|
||||
// - otherwise the text would be inserted while being in command mode
|
||||
if (input.text().isEmpty())
|
||||
handled = EventUnhandled;
|
||||
handled = false;
|
||||
}
|
||||
|
||||
updateMiniBuffer();
|
||||
@@ -4793,8 +4799,8 @@ EventResult FakeVimHandler::Private::handleSearchSubSubMode(const Input &input)
|
||||
}
|
||||
if (g.currentMessage.isEmpty())
|
||||
showMessage(MessageCommand, g.searchBuffer.display());
|
||||
else
|
||||
handled = EventCancelled;
|
||||
else if (g.currentMessageLevel == MessageError)
|
||||
handled = EventCancelled; // Not found so cancel mapping if any.
|
||||
enterCommandMode(g.returnToMode);
|
||||
resetCommandMode();
|
||||
g.searchBuffer.clear();
|
||||
@@ -6045,7 +6051,10 @@ void FakeVimHandler::Private::miniBufferTextEdited(const QString &text, int curs
|
||||
editor()->setFocus();
|
||||
} else if (text.isEmpty()) {
|
||||
// editing cancelled
|
||||
enterFakeVim();
|
||||
handleDefaultKey(Input(Qt::Key_Escape, Qt::NoModifier, QString()));
|
||||
leaveFakeVim();
|
||||
|
||||
editor()->setFocus();
|
||||
updateCursorShape();
|
||||
} else {
|
||||
@@ -6347,6 +6356,11 @@ void FakeVimHandler::Private::scrollToLine(int line)
|
||||
{
|
||||
const QTextCursor tc = EDITOR(textCursor());
|
||||
|
||||
// Don't scroll if the line is already at the top.
|
||||
updateFirstVisibleLine();
|
||||
if (line == m_firstVisibleLine)
|
||||
return;
|
||||
|
||||
QTextCursor tc2 = tc;
|
||||
tc2.setPosition(document()->lastBlock().position());
|
||||
EDITOR(setTextCursor(tc2));
|
||||
|
||||
Reference in New Issue
Block a user