Commit 6e5018ef authored by Lukas Holecek's avatar Lukas Holecek Committed by hjk
Browse files

fakevim: Fix inclusive/exclusive delete



Change-Id: I1b46bda3f70a533d149cf38de02d89e2cf706f3f
Reviewed-by: default avatarhjk <qthjk@ovi.com>
parent a99874c0
...@@ -2439,8 +2439,10 @@ void FakeVimPlugin::test_vim_visual_d() ...@@ -2439,8 +2439,10 @@ void FakeVimPlugin::test_vim_visual_d()
setup(&data); setup(&data);
data.setText(testLines); data.setText(testLines);
KEYS("vd", "|" + lmid(0)); KEYS("vd", "|" + lmid(1));
KEYS("vx", "|" + lmid(0)); KEYS("u", "|" + lmid(0));
KEYS("vx", "|" + lmid(1));
KEYS("u", "|" + lmid(0));
KEYS("vjd", "|" + lmid(1).mid(1)); KEYS("vjd", "|" + lmid(1).mid(1));
KEYS("u", "|" + lmid(0)); KEYS("u", "|" + lmid(0));
KEYS("j", lmid(0, 1)+"\n" + "|" + lmid(1)); KEYS("j", lmid(0, 1)+"\n" + "|" + lmid(1));
......
...@@ -2595,7 +2595,12 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommandMovement) ...@@ -2595,7 +2595,12 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommandMovement)
g.returnToMode = InsertMode; g.returnToMode = InsertMode;
} else if (m_submode == DeleteSubMode) { } else if (m_submode == DeleteSubMode) {
setUndoPosition(); setUndoPosition();
removeText(currentRange()); const int pos = position();
// Always delete something (e.g. 'dw' on an empty line deletes the line).
if (pos == anchor() && m_movetype == MoveInclusive)
removeText(Range(pos, pos + 1));
else
removeText(currentRange());
dotCommand = QString('d'); dotCommand = QString('d');
if (m_movetype == MoveLineWise) if (m_movetype == MoveLineWise)
handleStartOfLine(); handleStartOfLine();
...@@ -2998,7 +3003,7 @@ bool FakeVimHandler::Private::handleMovement(const Input &input) ...@@ -2998,7 +3003,7 @@ bool FakeVimHandler::Private::handleMovement(const Input &input)
if (count > 1) if (count > 1)
moveDown(count - 1); moveDown(count - 1);
moveToEndOfLine(); moveToEndOfLine();
m_movetype = MoveInclusive; m_movetype = atEmptyLine() ? MoveExclusive : MoveInclusive;
setTargetColumn(); setTargetColumn();
if (m_submode == NoSubMode) if (m_submode == NoSubMode)
m_targetColumn = -1; m_targetColumn = -1;
...@@ -6680,9 +6685,15 @@ QString FakeVimHandler::Private::visualDotCommand() const ...@@ -6680,9 +6685,15 @@ QString FakeVimHandler::Private::visualDotCommand() const
void FakeVimHandler::Private::selectTextObject(bool simple, bool inner) void FakeVimHandler::Private::selectTextObject(bool simple, bool inner)
{ {
bool setupAnchor = (position() == anchor()); bool setupAnchor = (position() == anchor());
const int repeat = count();
// set anchor if not already set // set anchor if not already set
if (setupAnchor) { if (setupAnchor) {
// Select nothing with 'inner' on empty line.
if (inner && atEmptyLine() && repeat == 1) {
m_movetype = MoveExclusive;
return;
}
moveToBoundaryStart(1, simple, false); moveToBoundaryStart(1, simple, false);
setAnchor(); setAnchor();
} else { } else {
...@@ -6691,7 +6702,6 @@ void FakeVimHandler::Private::selectTextObject(bool simple, bool inner) ...@@ -6691,7 +6702,6 @@ void FakeVimHandler::Private::selectTextObject(bool simple, bool inner)
moveRight(); moveRight();
} }
const int repeat = count();
if (inner) { if (inner) {
moveToBoundaryEnd(repeat, simple); moveToBoundaryEnd(repeat, simple);
} else { } else {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment