From 74f4e27970e2cfc64f4eb1b3beb2cb420e136f91 Mon Sep 17 00:00:00 2001 From: ketmar Date: Tue, 26 Apr 2022 07:36:46 +0000 Subject: [PATCH] do not reset cursor position if it was on a purged message FossilOrigin-Name: b54068feae040181b99a91c48ac51ae73b79461116234092b3271248933e5110 --- chiroptera.d | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/chiroptera.d b/chiroptera.d index 5adc19e..1a1423c 100644 --- a/chiroptera.d +++ b/chiroptera.d @@ -2042,8 +2042,45 @@ final class MainPaneWindow : SubWindow { private void switchToFolderTid (const uint tid, bool forced=false) { //setupTrayAnimation(); if (!forced && tid == lastDecodedTid) return; - saveThreadListPositions(); - if (lastDecodedTid != 0) chiroDeletePurgedWithTag(lastDecodedTid); + if (lastDecodedTid != 0) { + // also, move down if deleted + int app = chiroGetMessageAppearance(lastDecodedTid, msglistCurrUId); + if (app == Appearance.SoftDeletePurge) { + immutable uint origmsgid = msglistCurrUId; + bool needGoUp = false; + // go down + while (app == Appearance.SoftDeletePurge) { + immutable uint nextUid = chiroGetTreePaneTableNextUid(msglistCurrUId); + if (!nextUid || nextUid == msglistCurrUId) { + // oops + needGoUp = true; + //conwriteln("need to go up..."); + break; + } + msglistCurrUId = nextUid; + app = chiroGetMessageAppearance(lastDecodedTid, msglistCurrUId); + } + // try up? + if (needGoUp) { + msglistCurrUId = origmsgid; + app = Appearance.SoftDeletePurge; // guaranteed + // go up + while (app == Appearance.SoftDeletePurge) { + immutable uint prevUid = chiroGetTreePaneTablePrevUid(msglistCurrUId); + if (!prevUid || prevUid == msglistCurrUId) { + // oops + //conwriteln("...ooops"); + break; + } + msglistCurrUId = prevUid; + app = chiroGetMessageAppearance(lastDecodedTid, msglistCurrUId); + } + } + } + chiroDeletePurgedWithTag(lastDecodedTid); + threadListPositionDirty(); + saveThreadListPositions(); + } // rescan lastDecodedTid = tid; if (tid != 0) { -- 2.11.4.GIT