vim-mode: bug fix in block cursor mode

This commit is contained in:
Le Tan 2017-12-03 16:21:00 +08:00
parent 262c6acfd9
commit 7f230312df
2 changed files with 6 additions and 2 deletions

View File

@ -3987,8 +3987,6 @@ void VVim::processPasteAction(QList<Token> &p_tokens, bool p_pasteBefore)
changed = true;
}
setMode(VimMode::Normal);
} else {
// Normal mode.
if (isBlock) {
@ -4041,6 +4039,10 @@ void VVim::processPasteAction(QList<Token> &p_tokens, bool p_pasteBefore)
cursor.endEditBlock();
if (!checkMode(VimMode::Normal)) {
setMode(VimMode::Normal);
}
if (changed) {
m_editor->setTextCursorW(cursor);
}

View File

@ -314,6 +314,7 @@ QVector<QTextLayout::FormatRange> VTextDocumentLayout::formatRangeFromSelection(
// a position to specify the line. that's more convenience in usage.
QTextLayout::FormatRange o;
QTextLine l = p_block.layout()->lineForTextPosition(range.cursor.position() - blpos);
Q_ASSERT(l.isValid());
o.start = l.textStart();
o.length = l.textLength();
if (o.start + o.length == bllen - 1) {
@ -1087,6 +1088,7 @@ int VTextDocumentLayout::getTextWidthWithinTextLine(const QTextLayout *p_layout,
int p_length)
{
QTextLine line = p_layout->lineForTextPosition(p_pos);
Q_ASSERT(line.isValid());
Q_ASSERT(p_pos + p_length <= line.textStart() + line.textLength());
return line.cursorToX(p_pos + p_length) - line.cursorToX(p_pos);
}