mirror of
https://gitee.com/vnotex/vnote.git
synced 2025-07-05 13:59:52 +08:00
MdTab: do not scroll editor when it is under the right header while entering edit mode
This commit is contained in:
parent
377c00c25d
commit
d66b4752d4
@ -168,7 +168,7 @@ bool VMdTab::scrollWebViewToHeader(const VHeaderPointer &p_header)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VMdTab::scrollEditorToHeader(const VHeaderPointer &p_header)
|
||||
bool VMdTab::scrollEditorToHeader(const VHeaderPointer &p_header, bool p_force)
|
||||
{
|
||||
if (!m_outline.isMatched(p_header)
|
||||
|| m_outline.getType() != VTableOfContentType::BlockNumber) {
|
||||
@ -202,6 +202,17 @@ 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.
|
||||
if (!p_force) {
|
||||
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;
|
||||
@ -253,7 +264,7 @@ void VMdTab::showFileEditMode()
|
||||
VUtils::sleepWait(100);
|
||||
}
|
||||
|
||||
scrollEditorToHeader(header);
|
||||
scrollEditorToHeader(header, false);
|
||||
|
||||
mdEdit->setFocus();
|
||||
}
|
||||
|
@ -185,7 +185,8 @@ private:
|
||||
// Return true if scroll was made.
|
||||
bool scrollWebViewToHeader(const VHeaderPointer &p_header);
|
||||
|
||||
bool scrollEditorToHeader(const VHeaderPointer &p_header);
|
||||
// @p_force: when true, will scroll even current mouse is under the specified header.
|
||||
bool scrollEditorToHeader(const VHeaderPointer &p_header, bool p_force = true);
|
||||
|
||||
// Scroll web/editor to given header.
|
||||
// Return true if scroll was made.
|
||||
|
Loading…
x
Reference in New Issue
Block a user