diff --git a/scintilla/src/EditModel.cxx b/scintilla/src/EditModel.cxx index c197eedad2..027e3ccf7b 100644 --- a/scintilla/src/EditModel.cxx +++ b/scintilla/src/EditModel.cxx @@ -86,6 +86,7 @@ EditModel::EditModel() : durationWrapOneUnit(0.01 / 64), durationWrapOneThread(0 GetNativeSystemInfo(&info); hardwareConcurrency = info.dwNumberOfProcessors; idleTaskTimer = CreateWaitableTimer(nullptr, true, nullptr); + SetIdleTaskTime(IdleLineWrapTime); UpdateParallelLayoutThreshold(); } diff --git a/scintilla/src/EditModel.h b/scintilla/src/EditModel.h index 1fc7b67e24..44ba4d061c 100644 --- a/scintilla/src/EditModel.h +++ b/scintilla/src/EditModel.h @@ -58,7 +58,6 @@ class EditModel { ActionDuration durationWrapOneUnit; ActionDuration durationWrapOneThread; static constexpr uint32_t IdleLineWrapTime = 250; - static constexpr uint32_t ActiveLineWrapTime = 500; void *idleTaskTimer; EditModel(); diff --git a/scintilla/src/EditView.cxx b/scintilla/src/EditView.cxx index 704a1019a1..c953964e24 100644 --- a/scintilla/src/EditView.cxx +++ b/scintilla/src/EditView.cxx @@ -430,13 +430,16 @@ struct LayoutWorker { } } - uint32_t Start(Sci::Position posLineStart, uint32_t posInLine) { + uint32_t Start(Sci::Position posLineStart, uint32_t posInLine, LayoutLineOption option) { const int startPos = ll->lastSegmentEnd; const int endPos = ll->numCharsInLine; if (endPos - startPos > blockSize*2 && !model.BidirectionalEnabled()) { posInLine = std::max(posInLine, ll->caretPosition) + blockSize; if (posInLine > static_cast(endPos)) { posInLine = endPos; + } else if (option < LayoutLineOption::IdleUpdate) { + // layout as much as possible to avoid unexpected scrolling + model.SetIdleTaskTime(EditModel::IdleLineWrapTime); } } else { posInLine = endPos; @@ -663,7 +666,7 @@ uint64_t EditView::LayoutLine(const EditModel &model, Surface *surface, const Vi //const ElapsedPeriod period; //posInLine = ll->numCharsInLine; // whole line LayoutWorker worker{ ll, vstyle, surface, posCache, model, {}}; - const uint32_t threadCount = worker.Start(posLineStart, posInLine); + const uint32_t threadCount = worker.Start(posLineStart, posInLine, option); // Accumulate absolute positions from relative positions within segments and expand tabs const uint32_t finishedCount = worker.finishedCount.load(std::memory_order_relaxed); diff --git a/scintilla/src/EditView.h b/scintilla/src/EditView.h index 17bfeb147b..3c11dd2327 100644 --- a/scintilla/src/EditView.h +++ b/scintilla/src/EditView.h @@ -36,6 +36,7 @@ enum class DrawPhase { enum class LayoutLineOption { AutoUpdate, ManualUpdate, + IdleUpdate, KeepPosition, Printing, CallerMultiThreaded = 8, diff --git a/scintilla/src/Editor.cxx b/scintilla/src/Editor.cxx index 62da7f0fc3..d910bfe721 100644 --- a/scintilla/src/Editor.cxx +++ b/scintilla/src/Editor.cxx @@ -1525,7 +1525,7 @@ bool Editor::WrapBlock(Surface *surface, Sci::Line lineToWrap, Sci::Line lineToW } else { ll->caretPosition = 0; } - const uint64_t wrappedBytes = view.LayoutLine(*this, surface, vs, ll, wrapWidth, LayoutLineOption::ManualUpdate); + const uint64_t wrappedBytes = view.LayoutLine(*this, surface, vs, ll, wrapWidth, LayoutLineOption::IdleUpdate); wrappedBytesAllThread += wrappedBytes & UINT32_MAX; wrappedBytesOneThread += wrappedBytes >> 32; linesAfterWrap[index] = ll->lines; @@ -3014,8 +3014,6 @@ void Editor::NotifyMacroRecord(Message iMessage, uptr_t wParam, sptr_t lParam) n // Something has changed that the container should know about void Editor::ContainerNeedsUpdate(Update flags) noexcept { needUpdateUI = needUpdateUI | flags; - // layout as much as possible inside LayoutLine() to avoid unexpected scrolling - SetIdleTaskTime(ActiveLineWrapTime); } /** diff --git a/scintilla/win32/ScintillaWin.cxx b/scintilla/win32/ScintillaWin.cxx index 76b668b4a8..66d1dfffc6 100644 --- a/scintilla/win32/ScintillaWin.cxx +++ b/scintilla/win32/ScintillaWin.cxx @@ -2351,6 +2351,7 @@ sptr_t ScintillaWin::WndProc(Message iMessage, uptr_t wParam, sptr_t lParam) { case WM_SETREDRAW: ::DefWindowProc(MainHWND(), msg, wParam, lParam); if (wParam) { + SetIdleTaskTime(IdleLineWrapTime); SetScrollBars(); SetVerticalScrollPos(); SetHorizontalScrollPos();