FakeVim: Command % jumps to first known parenthesis character

Change-Id: I28988925f397af8c4927c416774d7fe21e982dcb
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
hluk
2013-11-30 19:53:23 +01:00
committed by hjk
parent 8ea6a21a78
commit 227ef8240a
3 changed files with 100 additions and 4 deletions

View File

@@ -6517,11 +6517,22 @@ void FakeVimHandler::Private::moveToMatchingParanthesis()
const int anc = anchor();
QTextCursor tc = m_cursor;
// If no known parenthesis symbol is under cursor find one on the current line after cursor.
static const QString parenthesesChars(_("([{}])"));
while (!parenthesesChars.contains(document()->characterAt(tc.position())) && !tc.atBlockEnd())
tc.setPosition(tc.position() + 1);
if (tc.atBlockEnd())
tc = m_cursor;
emit q->moveToMatchingParenthesis(&moved, &forward, &tc);
if (moved && forward)
tc.movePosition(Left, KeepAnchor, 1);
setAnchorAndPosition(anc, tc.position());
setTargetColumn();
if (moved) {
if (forward)
tc.movePosition(Left, KeepAnchor, 1);
setAnchorAndPosition(anc, tc.position());
setTargetColumn();
}
}
int FakeVimHandler::Private::cursorLineOnScreen() const