From b7fa135956ab6703982eab91de6f6c501c9db055 Mon Sep 17 00:00:00 2001 From: Le Tan Date: Wed, 3 Apr 2019 21:53:18 +0800 Subject: [PATCH] MdTab: fix focus issue when toggling edit mode in a note without outline --- src/vmdtab.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/vmdtab.cpp b/src/vmdtab.cpp index 0c6e3051..7aa8bd9c 100644 --- a/src/vmdtab.cpp +++ b/src/vmdtab.cpp @@ -266,12 +266,13 @@ void VMdTab::showFileEditMode() // Generally, beginEdit() will generate the headers. Wait is needed when // highlight completion is going to re-generate the headers. int nrRetry = 10; - while (header.m_index > -1 - && nrRetry-- > 0 - && (m_outline.isEmpty() || m_outline.getType() != VTableOfContentType::BlockNumber)) { - qDebug() << "wait another 100 ms for editor's headers ready"; + do { + // We still need to wait even when there is no header to scroll since + // setCurrentMode()'s sendPostedEvents(). VUtils::sleepWait(100); - } + } while (header.m_index > -1 + && nrRetry-- >= 0 + && (m_outline.isEmpty() || m_outline.getType() != VTableOfContentType::BlockNumber)); scrollEditorToHeader(header, false);