VMdTab: do not change the cursor if it is below the right title when entering the read mode

This commit is contained in:
Le Tan 2018-01-02 20:42:08 +08:00
parent 6ba12f7932
commit 3f3a0e8513

View File

@ -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;