forked from qt-creator/qt-creator
fakevim: Improved repeat command
Repeat commands in visual mode correctly. Task-number: QTCREATORBUG-7248 Change-Id: I937688f669f9bb9e1ad5f64b42dc0ee56dc3ca38 Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -122,14 +122,12 @@ struct TestData
|
|||||||
|
|
||||||
void setText(const QString &text)
|
void setText(const QString &text)
|
||||||
{
|
{
|
||||||
QTextCursor tc = cursor();
|
|
||||||
QString str = text;
|
QString str = text;
|
||||||
int i = str.indexOf(cursorString);
|
int i = str.indexOf(cursorString);
|
||||||
if (!cursorString.isEmpty() && i != -1)
|
if (!cursorString.isEmpty() && i != -1)
|
||||||
str.remove(i, 1);
|
str.remove(i, 1);
|
||||||
edit->document()->setPlainText(str);
|
edit->document()->setPlainText(str);
|
||||||
tc.setPosition(qMax(0, i));
|
handler->setTextCursorPosition(i);
|
||||||
edit->setTextCursor(tc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void doCommand(const QString &cmd) { handler->handleCommand(cmd); }
|
void doCommand(const QString &cmd) { handler->handleCommand(cmd); }
|
||||||
@@ -404,19 +402,50 @@ void FakeVimPlugin::test_vim_block_selection()
|
|||||||
|
|
||||||
void FakeVimPlugin::test_vim_repeat()
|
void FakeVimPlugin::test_vim_repeat()
|
||||||
{
|
{
|
||||||
NOT_IMPLEMENTED
|
|
||||||
|
|
||||||
TestData data;
|
TestData data;
|
||||||
setup(&data);
|
setup(&data);
|
||||||
|
|
||||||
data.setText("test text");
|
// delete line
|
||||||
KEYS("ciwWORD", "WOR" X "D text");
|
data.setText("abc" N "def" N "ghi");
|
||||||
|
KEYS("dd", X "def" N "ghi");
|
||||||
|
KEYS(".", X "ghi");
|
||||||
|
|
||||||
|
// delete to next word
|
||||||
|
data.setText("abc def ghi jkl");
|
||||||
|
KEYS("dw", X "def ghi jkl");
|
||||||
|
KEYS("w.", "def " X "jkl");
|
||||||
|
KEYS("gg.", X "jkl");
|
||||||
|
|
||||||
|
// change in word
|
||||||
|
data.setText("WORD text");
|
||||||
|
KEYS("ciwWORD<esc>", "WOR" X "D text");
|
||||||
KEYS("w.", "WORD WOR" X "D");
|
KEYS("w.", "WORD WOR" X "D");
|
||||||
|
|
||||||
/* QTCREATORBUG-7248 */
|
/* QTCREATORBUG-7248 */
|
||||||
data.setText("test tex" X "t");
|
data.setText("test tex" X "t");
|
||||||
KEYS("vbcWORD", "test " "WOR" X "D");
|
KEYS("vbcWORD<esc>", "test " "WOR" X "D");
|
||||||
KEYS("bb.", X "WORD WORD");
|
KEYS("bb.", "WOR" X "D WORD");
|
||||||
|
|
||||||
|
// delete selected range
|
||||||
|
data.setText("abc def ghi jkl");
|
||||||
|
KEYS("viwd", X " def ghi jkl");
|
||||||
|
KEYS(".", X "f ghi jkl");
|
||||||
|
KEYS(".", X "hi jkl");
|
||||||
|
|
||||||
|
// delete two lines
|
||||||
|
data.setText("abc" N "def" N "ghi" N "jkl" N "mno");
|
||||||
|
KEYS("Vjx", X "ghi" N "jkl" N "mno");
|
||||||
|
KEYS(".", X "mno");
|
||||||
|
|
||||||
|
// delete three lines
|
||||||
|
data.setText("abc" N "def" N "ghi" N "jkl" N "mno" N "pqr" N "stu");
|
||||||
|
KEYS("d2j", X "jkl" N "mno" N "pqr" N "stu");
|
||||||
|
KEYS(".", X "stu");
|
||||||
|
|
||||||
|
// replace block selection
|
||||||
|
data.setText("abcd" N "d" X "efg" N "ghij" N "jklm");
|
||||||
|
KEYS("<c-v>jlrX", "abcd" N "d" X "XXg" N "gXXj" N "jklm");
|
||||||
|
KEYS("gg.", "XXcd" N "XXXg" N "gXXj" N "jklm");
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimPlugin::test_vim_search()
|
void FakeVimPlugin::test_vim_search()
|
||||||
|
|||||||
@@ -1157,8 +1157,8 @@ public:
|
|||||||
EventResult handleCloseSquareSubMode(const Input &);
|
EventResult handleCloseSquareSubMode(const Input &);
|
||||||
EventResult handleSearchSubSubMode(const Input &);
|
EventResult handleSearchSubSubMode(const Input &);
|
||||||
EventResult handleCommandSubSubMode(const Input &);
|
EventResult handleCommandSubSubMode(const Input &);
|
||||||
void finishMovement(const QString &dotCommand = QString());
|
void finishMovement(const QString &dotCommandMovement = QString());
|
||||||
void finishMovement(const QString &dotCommand, int count);
|
void finishMovement(const QString &dotCommandMovement, int count);
|
||||||
void resetCommandMode();
|
void resetCommandMode();
|
||||||
void search(const SearchData &sd, bool showMessages = true);
|
void search(const SearchData &sd, bool showMessages = true);
|
||||||
void searchNext(bool forward = true);
|
void searchNext(bool forward = true);
|
||||||
@@ -1438,6 +1438,7 @@ public:
|
|||||||
void replay(const QString &text, int count);
|
void replay(const QString &text, int count);
|
||||||
void setDotCommand(const QString &cmd) { g.dotCommand = cmd; }
|
void setDotCommand(const QString &cmd) { g.dotCommand = cmd; }
|
||||||
void setDotCommand(const QString &cmd, int n) { g.dotCommand = cmd.arg(n); }
|
void setDotCommand(const QString &cmd, int n) { g.dotCommand = cmd.arg(n); }
|
||||||
|
QString visualDotCommand() const;
|
||||||
|
|
||||||
// extra data for ';'
|
// extra data for ';'
|
||||||
QString m_semicolonCount;
|
QString m_semicolonCount;
|
||||||
@@ -2156,12 +2157,12 @@ void FakeVimHandler::Private::moveToStartOfLine()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimHandler::Private::finishMovement(const QString &dotCommand, int count)
|
void FakeVimHandler::Private::finishMovement(const QString &dotCommandMovement, int count)
|
||||||
{
|
{
|
||||||
finishMovement(dotCommand.arg(count));
|
finishMovement(dotCommandMovement.arg(count));
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
void FakeVimHandler::Private::finishMovement(const QString &dotCommandMovement)
|
||||||
{
|
{
|
||||||
//dump("FINISH MOVEMENT");
|
//dump("FINISH MOVEMENT");
|
||||||
if (m_submode == FilterSubMode) {
|
if (m_submode == FilterSubMode) {
|
||||||
@@ -2250,8 +2251,8 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
|||||||
if (m_rangemode == RangeLineMode)
|
if (m_rangemode == RangeLineMode)
|
||||||
m_rangemode = RangeLineModeExclusive;
|
m_rangemode = RangeLineModeExclusive;
|
||||||
removeText(currentRange());
|
removeText(currentRange());
|
||||||
if (!dotCommand.isEmpty())
|
if (!dotCommandMovement.isEmpty())
|
||||||
setDotCommand(QLatin1Char('c') + dotCommand);
|
setDotCommand(QLatin1Char('c') + dotCommandMovement);
|
||||||
if (m_movetype == MoveLineWise)
|
if (m_movetype == MoveLineWise)
|
||||||
insertAutomaticIndentation(true);
|
insertAutomaticIndentation(true);
|
||||||
endEditBlock();
|
endEditBlock();
|
||||||
@@ -2261,8 +2262,8 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
|||||||
setUndoPosition();
|
setUndoPosition();
|
||||||
Range range = currentRange();
|
Range range = currentRange();
|
||||||
removeText(range);
|
removeText(range);
|
||||||
if (!dotCommand.isEmpty())
|
if (!dotCommandMovement.isEmpty())
|
||||||
setDotCommand(QLatin1Char('d') + dotCommand);
|
setDotCommand(QLatin1Char('d') + dotCommandMovement);
|
||||||
if (m_movetype == MoveLineWise)
|
if (m_movetype == MoveLineWise)
|
||||||
handleStartOfLine();
|
handleStartOfLine();
|
||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
@@ -2287,16 +2288,16 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
|||||||
} else if (m_submode == TransformSubMode) {
|
} else if (m_submode == TransformSubMode) {
|
||||||
if (m_subsubmode == InvertCaseSubSubMode) {
|
if (m_subsubmode == InvertCaseSubSubMode) {
|
||||||
invertCase(currentRange());
|
invertCase(currentRange());
|
||||||
if (!dotCommand.isEmpty())
|
if (!dotCommandMovement.isEmpty())
|
||||||
setDotCommand(QLatin1Char('~') + dotCommand);
|
setDotCommand(QLatin1Char('~') + dotCommandMovement);
|
||||||
} else if (m_subsubmode == UpCaseSubSubMode) {
|
} else if (m_subsubmode == UpCaseSubSubMode) {
|
||||||
upCase(currentRange());
|
upCase(currentRange());
|
||||||
if (!dotCommand.isEmpty())
|
if (!dotCommandMovement.isEmpty())
|
||||||
setDotCommand("gU" + dotCommand);
|
setDotCommand("gU" + dotCommandMovement);
|
||||||
} else if (m_subsubmode == DownCaseSubSubMode) {
|
} else if (m_subsubmode == DownCaseSubSubMode) {
|
||||||
downCase(currentRange());
|
downCase(currentRange());
|
||||||
if (!dotCommand.isEmpty())
|
if (!dotCommandMovement.isEmpty())
|
||||||
setDotCommand("gu" + dotCommand);
|
setDotCommand("gu" + dotCommandMovement);
|
||||||
}
|
}
|
||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
m_subsubmode = NoSubSubMode;
|
m_subsubmode = NoSubSubMode;
|
||||||
@@ -2309,22 +2310,22 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
|||||||
setUndoPosition();
|
setUndoPosition();
|
||||||
indentSelectedText();
|
indentSelectedText();
|
||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
if (!dotCommand.isEmpty())
|
if (!dotCommandMovement.isEmpty())
|
||||||
setDotCommand('=' + dotCommand);
|
setDotCommand('=' + dotCommandMovement);
|
||||||
} else if (m_submode == ShiftRightSubMode) {
|
} else if (m_submode == ShiftRightSubMode) {
|
||||||
recordJump();
|
recordJump();
|
||||||
setUndoPosition();
|
setUndoPosition();
|
||||||
shiftRegionRight(1);
|
shiftRegionRight(1);
|
||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
if (!dotCommand.isEmpty())
|
if (!dotCommandMovement.isEmpty())
|
||||||
setDotCommand('>' + dotCommand);
|
setDotCommand('>' + dotCommandMovement);
|
||||||
} else if (m_submode == ShiftLeftSubMode) {
|
} else if (m_submode == ShiftLeftSubMode) {
|
||||||
recordJump();
|
recordJump();
|
||||||
setUndoPosition();
|
setUndoPosition();
|
||||||
shiftRegionLeft(1);
|
shiftRegionLeft(1);
|
||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
if (!dotCommand.isEmpty())
|
if (!dotCommandMovement.isEmpty())
|
||||||
setDotCommand('<' + dotCommand);
|
setDotCommand('<' + dotCommandMovement);
|
||||||
}
|
}
|
||||||
|
|
||||||
resetCommandMode();
|
resetCommandMode();
|
||||||
@@ -2589,6 +2590,7 @@ EventResult FakeVimHandler::Private::handleCommandMode(const Input &input)
|
|||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
m_rangemode = RangeLineMode;
|
m_rangemode = RangeLineMode;
|
||||||
} else if (m_submode == ReplaceSubMode) {
|
} else if (m_submode == ReplaceSubMode) {
|
||||||
|
setDotCommand(visualDotCommand() + 'r' + input.asChar());
|
||||||
if (isVisualMode()) {
|
if (isVisualMode()) {
|
||||||
setUndoPosition();
|
setUndoPosition();
|
||||||
if (isVisualLineMode())
|
if (isVisualLineMode())
|
||||||
@@ -2837,7 +2839,7 @@ EventResult FakeVimHandler::Private::handleCommandMode1(const Input &input)
|
|||||||
// << input;
|
// << input;
|
||||||
QString savedCommand = g.dotCommand;
|
QString savedCommand = g.dotCommand;
|
||||||
g.dotCommand.clear();
|
g.dotCommand.clear();
|
||||||
replay(savedCommand, count());
|
replay(savedCommand, 1);
|
||||||
enterCommandMode();
|
enterCommandMode();
|
||||||
g.dotCommand = savedCommand;
|
g.dotCommand = savedCommand;
|
||||||
} else if (input.is('<')) {
|
} else if (input.is('<')) {
|
||||||
@@ -2872,6 +2874,7 @@ EventResult FakeVimHandler::Private::handleCommandMode1(const Input &input)
|
|||||||
setUndoPosition();
|
setUndoPosition();
|
||||||
breakEditBlock();
|
breakEditBlock();
|
||||||
enterInsertMode();
|
enterInsertMode();
|
||||||
|
setDotCommand(QString(QLatin1Char('a')));
|
||||||
m_lastInsertion.clear();
|
m_lastInsertion.clear();
|
||||||
if (!atEndOfLine())
|
if (!atEndOfLine())
|
||||||
moveRight();
|
moveRight();
|
||||||
@@ -2887,6 +2890,7 @@ EventResult FakeVimHandler::Private::handleCommandMode1(const Input &input)
|
|||||||
updateMiniBuffer();
|
updateMiniBuffer();
|
||||||
} else if (input.isControl('a')) {
|
} else if (input.isControl('a')) {
|
||||||
changeNumberTextObject(true);
|
changeNumberTextObject(true);
|
||||||
|
setDotCommand("%1<c-a>", count());
|
||||||
} else if (input.is('b') || input.isShift(Key_Left)) {
|
} else if (input.is('b') || input.isShift(Key_Left)) {
|
||||||
m_movetype = MoveExclusive;
|
m_movetype = MoveExclusive;
|
||||||
moveToNextWordStart(count(), false, false);
|
moveToNextWordStart(count(), false, false);
|
||||||
@@ -2905,6 +2909,7 @@ EventResult FakeVimHandler::Private::handleCommandMode1(const Input &input)
|
|||||||
m_submode = ChangeSubMode;
|
m_submode = ChangeSubMode;
|
||||||
} else if ((input.is('c') || input.is('C') || input.is('s') || input.is('R'))
|
} else if ((input.is('c') || input.is('C') || input.is('s') || input.is('R'))
|
||||||
&& (isVisualCharMode() || isVisualLineMode())) {
|
&& (isVisualCharMode() || isVisualLineMode())) {
|
||||||
|
setDotCommand(visualDotCommand() + input.asChar());
|
||||||
if ((input.is('c')|| input.is('s')) && isVisualCharMode()) {
|
if ((input.is('c')|| input.is('s')) && isVisualCharMode()) {
|
||||||
leaveVisualMode();
|
leaveVisualMode();
|
||||||
m_rangemode = RangeCharMode;
|
m_rangemode = RangeCharMode;
|
||||||
@@ -2942,6 +2947,7 @@ EventResult FakeVimHandler::Private::handleCommandMode1(const Input &input)
|
|||||||
} else if ((input.is('d') || input.is('x') || input.isKey(Key_Delete))
|
} else if ((input.is('d') || input.is('x') || input.isKey(Key_Delete))
|
||||||
&& isVisualMode()) {
|
&& isVisualMode()) {
|
||||||
setUndoPosition();
|
setUndoPosition();
|
||||||
|
setDotCommand(visualDotCommand() + 'x');
|
||||||
if (isVisualCharMode()) {
|
if (isVisualCharMode()) {
|
||||||
leaveVisualMode();
|
leaveVisualMode();
|
||||||
m_submode = DeleteSubMode;
|
m_submode = DeleteSubMode;
|
||||||
@@ -2972,6 +2978,7 @@ EventResult FakeVimHandler::Private::handleCommandMode1(const Input &input)
|
|||||||
finishMovement();
|
finishMovement();
|
||||||
} else if ((input.is('D') || input.is('X')) &&
|
} else if ((input.is('D') || input.is('X')) &&
|
||||||
(isVisualCharMode() || isVisualLineMode())) {
|
(isVisualCharMode() || isVisualLineMode())) {
|
||||||
|
setDotCommand(visualDotCommand() + 'X');
|
||||||
leaveVisualMode();
|
leaveVisualMode();
|
||||||
m_rangemode = RangeLineMode;
|
m_rangemode = RangeLineMode;
|
||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
@@ -2979,6 +2986,7 @@ EventResult FakeVimHandler::Private::handleCommandMode1(const Input &input)
|
|||||||
removeText(currentRange());
|
removeText(currentRange());
|
||||||
moveToFirstNonBlankOnLine();
|
moveToFirstNonBlankOnLine();
|
||||||
} else if ((input.is('D') || input.is('X')) && isVisualBlockMode()) {
|
} else if ((input.is('D') || input.is('X')) && isVisualBlockMode()) {
|
||||||
|
setDotCommand(visualDotCommand() + 'X');
|
||||||
leaveVisualMode();
|
leaveVisualMode();
|
||||||
m_rangemode = RangeBlockAndTailMode;
|
m_rangemode = RangeBlockAndTailMode;
|
||||||
yankText(currentRange(), m_register);
|
yankText(currentRange(), m_register);
|
||||||
@@ -3102,7 +3110,6 @@ EventResult FakeVimHandler::Private::handleCommandMode2(const Input &input)
|
|||||||
moveDown(count());
|
moveDown(count());
|
||||||
finishMovement("%1j", count());
|
finishMovement("%1j", count());
|
||||||
} else if (input.is('J')) {
|
} else if (input.is('J')) {
|
||||||
setDotCommand("%1J", count());
|
|
||||||
beginEditBlock();
|
beginEditBlock();
|
||||||
if (m_submode == NoSubMode) {
|
if (m_submode == NoSubMode) {
|
||||||
for (int i = qMax(count(), 2) - 1; --i >= 0; ) {
|
for (int i = qMax(count(), 2) - 1; --i >= 0; ) {
|
||||||
@@ -3123,7 +3130,7 @@ EventResult FakeVimHandler::Private::handleCommandMode2(const Input &input)
|
|||||||
moveLeft();
|
moveLeft();
|
||||||
}
|
}
|
||||||
endEditBlock();
|
endEditBlock();
|
||||||
finishMovement();
|
finishMovement("%1J");
|
||||||
} else if (input.is('k') || input.isKey(Key_Up) || input.isControl('p')) {
|
} else if (input.is('k') || input.isKey(Key_Up) || input.isControl('p')) {
|
||||||
m_movetype = MoveLineWise;
|
m_movetype = MoveLineWise;
|
||||||
moveUp(count());
|
moveUp(count());
|
||||||
@@ -3142,6 +3149,7 @@ EventResult FakeVimHandler::Private::handleCommandMode2(const Input &input)
|
|||||||
moveUp(qMax(count(), 1));
|
moveUp(qMax(count(), 1));
|
||||||
handleStartOfLine();
|
handleStartOfLine();
|
||||||
finishMovement();
|
finishMovement();
|
||||||
|
finishMovement("%1L");
|
||||||
} else if (input.isControl('l')) {
|
} else if (input.isControl('l')) {
|
||||||
// screen redraw. should not be needed
|
// screen redraw. should not be needed
|
||||||
} else if (input.is('m')) {
|
} else if (input.is('m')) {
|
||||||
@@ -3335,6 +3343,7 @@ EventResult FakeVimHandler::Private::handleCommandMode2(const Input &input)
|
|||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (input.isControl('x')) {
|
} else if (input.isControl('x')) {
|
||||||
changeNumberTextObject(false);
|
changeNumberTextObject(false);
|
||||||
|
setDotCommand("%1<c-a>", count());
|
||||||
} else if (input.is('X')) {
|
} else if (input.is('X')) {
|
||||||
if (leftDist() > 0) {
|
if (leftDist() > 0) {
|
||||||
setAnchor();
|
setAnchor();
|
||||||
@@ -3447,12 +3456,12 @@ EventResult FakeVimHandler::Private::handleCommandMode2(const Input &input)
|
|||||||
moveDown(count() * (linesOnScreen() - 2) - cursorLineOnScreen());
|
moveDown(count() * (linesOnScreen() - 2) - cursorLineOnScreen());
|
||||||
scrollToLine(cursorLine());
|
scrollToLine(cursorLine());
|
||||||
handleStartOfLine();
|
handleStartOfLine();
|
||||||
finishMovement();
|
finishMovement("%1f", count());
|
||||||
} else if (input.isKey(Key_PageUp) || input.isControl('b')) {
|
} else if (input.isKey(Key_PageUp) || input.isControl('b')) {
|
||||||
moveUp(count() * (linesOnScreen() - 2) + cursorLineOnScreen());
|
moveUp(count() * (linesOnScreen() - 2) + cursorLineOnScreen());
|
||||||
scrollToLine(cursorLine() + linesOnScreen() - 2);
|
scrollToLine(cursorLine() + linesOnScreen() - 2);
|
||||||
handleStartOfLine();
|
handleStartOfLine();
|
||||||
finishMovement();
|
finishMovement("%1b", count());
|
||||||
} else if (input.isKey(Key_Delete)) {
|
} else if (input.isKey(Key_Delete)) {
|
||||||
setAnchor();
|
setAnchor();
|
||||||
moveRight(qMin(1, rightDist()));
|
moveRight(qMin(1, rightDist()));
|
||||||
@@ -5923,14 +5932,35 @@ void FakeVimHandler::Private::handleStartOfLine()
|
|||||||
void FakeVimHandler::Private::replay(const QString &command, int n)
|
void FakeVimHandler::Private::replay(const QString &command, int n)
|
||||||
{
|
{
|
||||||
//qDebug() << "REPLAY: " << quoteUnprintable(command);
|
//qDebug() << "REPLAY: " << quoteUnprintable(command);
|
||||||
|
Inputs inputs(command);
|
||||||
for (int i = n; --i >= 0; ) {
|
for (int i = n; --i >= 0; ) {
|
||||||
foreach (QChar c, command) {
|
foreach (Input in, inputs) {
|
||||||
//qDebug() << " REPLAY: " << c.unicode();
|
handleDefaultKey(in);
|
||||||
handleDefaultKey(Input(c));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString FakeVimHandler::Private::visualDotCommand() const
|
||||||
|
{
|
||||||
|
QTextCursor start(cursor());
|
||||||
|
QTextCursor end(start);
|
||||||
|
end.setPosition(end.anchor());
|
||||||
|
|
||||||
|
if (isVisualCharMode())
|
||||||
|
return QString("v%1l").arg(qAbs(start.position() - end.position()));
|
||||||
|
|
||||||
|
if (isVisualLineMode())
|
||||||
|
return QString("V%1j").arg(qAbs(start.blockNumber() - end.blockNumber()));
|
||||||
|
|
||||||
|
if (isVisualBlockMode()) {
|
||||||
|
return QString("<c-v>%1l%2j")
|
||||||
|
.arg(qAbs(start.positionInBlock() - end.positionInBlock()))
|
||||||
|
.arg(qAbs(start.blockNumber() - end.blockNumber()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
void FakeVimHandler::Private::selectTextObject(bool simple, bool inner)
|
void FakeVimHandler::Private::selectTextObject(bool simple, bool inner)
|
||||||
{
|
{
|
||||||
bool setupAnchor = (position() == anchor());
|
bool setupAnchor = (position() == anchor());
|
||||||
@@ -6401,6 +6431,16 @@ void FakeVimHandler::miniBufferTextEdited(const QString &text, int cursorPos)
|
|||||||
d->miniBufferTextEdited(text, cursorPos);
|
d->miniBufferTextEdited(text, cursorPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FakeVimHandler::setTextCursorPosition(int position)
|
||||||
|
{
|
||||||
|
int pos = qMax(0, qMin(position, d->lastPositionInDocument()));
|
||||||
|
if (d->isVisualMode())
|
||||||
|
d->setPosition(pos);
|
||||||
|
else
|
||||||
|
d->setAnchorAndPosition(pos, pos);
|
||||||
|
d->setTargetColumn();
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
} // namespace FakeVim
|
} // namespace FakeVim
|
||||||
|
|
||||||
|
|||||||
@@ -131,6 +131,9 @@ public slots:
|
|||||||
|
|
||||||
void miniBufferTextEdited(const QString &text, int cursorPos);
|
void miniBufferTextEdited(const QString &text, int cursorPos);
|
||||||
|
|
||||||
|
// Set text cursor position. Keeps anchor if in visual mode.
|
||||||
|
void setTextCursorPosition(int position);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void commandBufferChanged(const QString &msg, int pos, int messageLevel, QObject *eventFilter);
|
void commandBufferChanged(const QString &msg, int pos, int messageLevel, QObject *eventFilter);
|
||||||
void statusDataChanged(const QString &msg);
|
void statusDataChanged(const QString &msg);
|
||||||
|
|||||||
Reference in New Issue
Block a user