From 7f230312dfb36b53c1efa2105f2a566d4d711f83 Mon Sep 17 00:00:00 2001 From: Le Tan Date: Sun, 3 Dec 2017 16:21:00 +0800 Subject: [PATCH] vim-mode: bug fix in block cursor mode --- src/utils/vvim.cpp | 6 ++++-- src/vtextdocumentlayout.cpp | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/utils/vvim.cpp b/src/utils/vvim.cpp index 4df274a6..b0349a8b 100644 --- a/src/utils/vvim.cpp +++ b/src/utils/vvim.cpp @@ -3987,8 +3987,6 @@ void VVim::processPasteAction(QList &p_tokens, bool p_pasteBefore) changed = true; } - - setMode(VimMode::Normal); } else { // Normal mode. if (isBlock) { @@ -4041,6 +4039,10 @@ void VVim::processPasteAction(QList &p_tokens, bool p_pasteBefore) cursor.endEditBlock(); + if (!checkMode(VimMode::Normal)) { + setMode(VimMode::Normal); + } + if (changed) { m_editor->setTextCursorW(cursor); } diff --git a/src/vtextdocumentlayout.cpp b/src/vtextdocumentlayout.cpp index 436c8fea..a0a976a0 100644 --- a/src/vtextdocumentlayout.cpp +++ b/src/vtextdocumentlayout.cpp @@ -314,6 +314,7 @@ QVector 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); }