Commit 92bd228e authored by hluk's avatar hluk Committed by hjk

FakeVim: Correct range mode for registers

Change-Id: Ib58ced12ab8cff5917e17b8fc5022147d6f99f38
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 474459f4
......@@ -764,6 +764,12 @@ void FakeVimPlugin::test_vim_delete()
data.setText(" abc" N " def" N " gh" X "i" N " jkl");
KEYS("dk", " abc" N " " X "jkl");
INTEGRITY(false);
// delete with copy to a register
data.setText("abc" N "def");
KEYS("\"xd$", X "" N "def");
KEYS("\"xp", "ab" X "c" N "def");
KEYS("2\"xp", "abcabcab" X "c" N "def");
}
void FakeVimPlugin::test_vim_delete_inner_word()
......@@ -1013,6 +1019,12 @@ void FakeVimPlugin::test_vim_change_replace()
data.setText("abc" N "de" X "f" N "" N "jkl" N "mno");
KEYS("<c-v>2jh" "2s" "XYZ<esc>", "abc" N "d" X "XYZ" N "" N "jXYZ" N "mno");
INTEGRITY(false);
// change with copy to a register
data.setText("abc" N "def");
KEYS("\"xCxyz<esc>", "xy" X "z" N "def");
KEYS("\"xp", "xyzab" X "c" N "def");
KEYS("2\"xp", "xyzabcabcab" X "c" N "def");
}
void FakeVimPlugin::test_vim_block_selection()
......@@ -1970,6 +1982,10 @@ void FakeVimPlugin::test_vim_ex_yank()
COMMAND("$-1y", "abc" N X "def");
KEYS("P", "abc" N X "abc" N "def");
COMMAND("u", "abc" N X "def");
data.setText("abc" N "def");
KEYS("\"xy$", X "abc" N "def");
KEYS("\"xP", "ab" X "cabc" N "def");
}
void FakeVimPlugin::test_vim_ex_delete()
......
......@@ -3597,25 +3597,19 @@ bool FakeVimHandler::Private::handleNoSubMode(const Input &input)
setAnchor();
m_opcount = m_mvcount;
m_mvcount.clear();
m_rangemode = RangeCharMode;
m_movetype = MoveExclusive;
m_submode = input.is('c') ? ChangeSubMode : DeleteSubMode;
} else if ((input.is('c') || input.is('C') || input.is('s') || input.is('R'))
&& (isVisualCharMode() || isVisualLineMode())) {
setDotCommand(visualDotCommand() + input.asChar());
if ((input.is('c')|| input.is('s')) && isVisualCharMode()) {
leaveVisualMode();
m_rangemode = RangeCharMode;
} else {
leaveVisualMode();
m_rangemode = RangeLineMode;
// leaveVisualMode() has set this to MoveInclusive for visual character mode
m_movetype = MoveLineWise;
}
leaveVisualMode();
m_submode = ChangeSubMode;
finishMovement();
} else if (input.is('C')) {
setAnchor();
moveToEndOfLine();
m_rangemode = RangeCharMode;
m_submode = ChangeSubMode;
setDotCommand(QString(QLatin1Char('C')));
finishMovement();
......@@ -3634,13 +3628,11 @@ bool FakeVimHandler::Private::handleNoSubMode(const Input &input)
finishMovement();
} else if (isVisualLineMode()) {
leaveVisualMode();
m_rangemode = RangeLineMode;
yankText(currentRange(), m_register);
removeText(currentRange());
handleStartOfLine();
} else if (isVisualBlockMode()) {
leaveVisualMode();
m_rangemode = RangeBlockMode;
yankText(currentRange(), m_register);
removeText(currentRange());
setPosition(qMin(position(), anchor()));
......@@ -3864,6 +3856,7 @@ bool FakeVimHandler::Private::handleNoSubMode(const Input &input)
scrollUp(1);
} else if (input.is('y') && isNoVisualMode()) {
setAnchor();
m_rangemode = RangeCharMode;
m_movetype = MoveExclusive;
m_submode = YankSubMode;
} else if (input.is('y') && isVisualCharMode()) {
......@@ -6710,10 +6703,16 @@ void FakeVimHandler::Private::leaveVisualMode()
setMark(QLatin1Char('<'), mark(QLatin1Char('<')).position);
setMark(QLatin1Char('>'), mark(QLatin1Char('>')).position);
m_lastVisualModeInverted = anchor() > position();
if (isVisualLineMode())
if (isVisualLineMode()) {
m_rangemode = RangeLineMode;
m_movetype = MoveLineWise;
else if (isVisualCharMode())
} else if (isVisualCharMode()) {
m_rangemode = RangeCharMode;
m_movetype = MoveInclusive;
} else if (isVisualBlockMode()) {
m_rangemode = RangeBlockMode;
m_movetype = MoveInclusive;
}
m_visualMode = NoVisualMode;
updateMiniBuffer();
......
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