From 3f3a0e8513dd3b781fcbedbce245d9540dbaa722 Mon Sep 17 00:00:00 2001 From: Le Tan Date: Tue, 2 Jan 2018 20:42:08 +0800 Subject: [PATCH] VMdTab: do not change the cursor if it is below the right title when entering the read mode --- src/vmdtab.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/vmdtab.cpp b/src/vmdtab.cpp index bb6c7ae0..b082ea3e 100644 --- a/src/vmdtab.cpp +++ b/src/vmdtab.cpp @@ -165,6 +165,15 @@ bool VMdTab::scrollEditorToHeader(const VHeaderPointer &p_header) } } + // If the cursor are now under the right title, we should not change it right at + // the title. + int curBlockNumber = mdEdit->textCursor().block().blockNumber(); + if (m_outline.indexOfItemByBlockNumber(curBlockNumber) + == m_outline.indexOfItemByBlockNumber(blockNumber)) { + m_currentHeader = p_header; + return true; + } + if (mdEdit->scrollToHeader(blockNumber)) { m_currentHeader = p_header; return true;