Commit 1843d5ab authored by hluk's avatar hluk Committed by hjk

FakeVim: Check first character on line with 'F' and 'T' commands

Change-Id: Icd5c3ca62da0fbff35e2281e04b1fa37a304f64c
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
parent 75ce70a8
......@@ -693,6 +693,17 @@ void FakeVimPlugin::test_vim_fFtT()
KEYS("2F(", "123()456" N "a(b" X "(c)d)e");
KEYS("l2F(", "123()456" N "a" X "(b(c)d)e");
KEYS("F(", "123()456" N "a" X "(b(c)d)e");
data.setText("abc def" N "ghi " X "jkl");
KEYS("vFgx", "abc def" N X "kl");
KEYS("u", "abc def" N X "ghi jkl");
KEYS("tk", "abc def" N "ghi " X "jkl");
KEYS("dTg", "abc def" N "g" X "jkl");
INTEGRITY(false);
KEYS("u", "abc def" N "g" X "hi jkl");
KEYS("f .", "abc def" N "g" X " jkl");
KEYS("u", "abc def" N "g" X "hi jkl");
KEYS("rg$;", "abc def" N "gg" X "i jkl");
}
void FakeVimPlugin::test_vim_transform_numbers()
......
......@@ -6262,42 +6262,34 @@ void FakeVimHandler::Private::moveToWordEnd(int count, bool simple, bool forward
bool FakeVimHandler::Private::handleFfTt(QString key)
{
int key0 = key.size() == 1 ? key.at(0).unicode() : 0;
int oldPos = position();
// g.subsubmode \in { 'f', 'F', 't', 'T' }
bool forward = g.subsubdata.is('f') || g.subsubdata.is('t');
bool exclusive = g.subsubdata.is('t') || g.subsubdata.is('T');
int repeat = count();
int n = block().position() + (forward ? block().length() : - 1);
QTextDocument *doc = document();
int n = block().position();
if (forward)
n += block().length();
int pos = position();
while (pos != n) {
pos += forward ? 1 : -1;
if (pos == n)
break;
for (int d = forward ? 1 : -1, pos = position() + d; pos != n; pos += d) {
int uc = doc->characterAt(pos).unicode();
if (uc == ParagraphSeparator)
break;
if (uc == key0)
if (uc == key0) {
--repeat;
if (repeat == 0) {
if (g.subsubdata.is('t'))
--pos;
else if (g.subsubdata.is('T'))
++pos;
if (repeat == 0) {
if (exclusive)
pos -= d;
if (forward)
moveRight(pos - position());
else
moveLeft(position() - pos);
break;
if (forward)
moveRight(pos - position());
else
moveLeft(position() - pos);
setTargetColumn();
return true;
}
}
}
if (repeat == 0) {
setTargetColumn();
return true;
}
setPosition(oldPos);
return false;
}
......
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