From 484f1e1bf95b1cd80022893fa37ede18e00de826 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20K=C3=BCng?= Date: Sat, 6 Mar 2021 10:51:21 +0100 Subject: [PATCH] Fixes issue #3695: Keep the current line in the view when resizing with line-wrap on in TortoiseGitMerge MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stefan Küng Signed-off-by: Sven Strickroth --- src/Changelog.txt | 1 + src/TortoiseMerge/BaseView.cpp | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/src/Changelog.txt b/src/Changelog.txt index babc64a1a..824df37aa 100644 --- a/src/Changelog.txt +++ b/src/Changelog.txt @@ -16,6 +16,7 @@ Released: unreleased * Update pcre2 to 10.36 * Fixed issue #3693: Make short hash length for hyper-link in log message configurable * Fixed issue #3705: No "Move to Changelist" option in check for modifications dialog + * Fixes issue #3695: Keep the current line in the view when resizing with line-wrap on in TortoiseGitMerge == Bug Fixes == * Fixed issue #3649: "multi-project pull/fetch/push" not working diff --git a/src/TortoiseMerge/BaseView.cpp b/src/TortoiseMerge/BaseView.cpp index 0f84c3269..976e6bb63 100644 --- a/src/TortoiseMerge/BaseView.cpp +++ b/src/TortoiseMerge/BaseView.cpp @@ -2257,10 +2257,18 @@ void CBaseView::OnSize(UINT nType, int cx, int cy) m_nScreenChars = -1; if (m_nLastScreenChars != GetScreenChars()) { + auto oldCaretLine = m_ptCaretViewPos.y; BuildAllScreen2ViewVector(); m_nLastScreenChars = m_nScreenChars; if (m_pMainFrame && m_pMainFrame->m_bWrapLines) { + auto newCaretLine = FindScreenLineForViewLine(oldCaretLine); + int nNewTopLine = newCaretLine - GetScreenLines() / 2; + if (nNewTopLine < 0) + nNewTopLine = 0; + if (nNewTopLine >= static_cast(m_Screen2View.size())) + nNewTopLine = static_cast(m_Screen2View.size()) - 1; + ScrollToLine(nNewTopLine); // if we're in wrap mode, the line wrapping most likely changed // and that means we have to redraw the whole window, not just the // scrolled part. -- 2.11.4.GIT