From c640118dfaa39415d27cd7dcc48657ccd075f441 Mon Sep 17 00:00:00 2001 From: Le Tan Date: Wed, 7 Nov 2018 20:31:21 +0800 Subject: [PATCH] TextDocumentLayout: bug fix for block count change Example text that will make VNote crash: ``` ab123 aaa ``` Then select the space before `aaa` and press `Enter`. --- src/vtextdocumentlayout.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/vtextdocumentlayout.cpp b/src/vtextdocumentlayout.cpp index e17ef406..dd77c0c0 100644 --- a/src/vtextdocumentlayout.cpp +++ b/src/vtextdocumentlayout.cpp @@ -441,6 +441,7 @@ void VTextDocumentLayout::documentChanged(int p_from, int p_charsRemoved, int p_ // May be an invalid block. QTextBlock changeEndBlock; if (p_charsRemoved == p_charsAdded + && newBlockCount == m_blockCount && changeStartBlock.position() == p_from && changeStartBlock.length() == p_charsAdded) { // TODO: we may need one more next block. @@ -482,6 +483,8 @@ void VTextDocumentLayout::documentChanged(int p_from, int p_charsRemoved, int p_ updateOffset(changeStartBlock); } + m_blockCount = newBlockCount; + updateDocumentSize(); // TODO: Update the view of all the blocks after changeStartBlock.