From d63145c4bdc6b460fd81c9a435ab4fbb18f5806f Mon Sep 17 00:00:00 2001 From: ketmar Date: Tue, 26 Apr 2022 16:18:20 +0000 Subject: [PATCH] some cleanups for the previous commit FossilOrigin-Name: 0536888af527b009bd906130e8c16729a388924891eb3ea445c8aa6ee1e2676a --- chiroptera.d | 49 ++++++++++++++++++------------------------------- 1 file changed, 18 insertions(+), 31 deletions(-) diff --git a/chiroptera.d b/chiroptera.d index 1a1423c..493dccd 100644 --- a/chiroptera.d +++ b/chiroptera.d @@ -2044,41 +2044,28 @@ final class MainPaneWindow : SubWindow { if (!forced && tid == lastDecodedTid) return; 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) { + immutable uint origmsgid = msglistCurrUId; + bool godown = true; // go down first + for (;;) { + int app = chiroGetMessageAppearance(lastDecodedTid, msglistCurrUId); + if (app != Appearance.SoftDeletePurge) break; + immutable uint muid = + (godown ? chiroGetTreePaneTableNextUid(msglistCurrUId) : + chiroGetTreePaneTablePrevUid(msglistCurrUId)); + // anyway + threadListPositionDirty(); + if (!muid || muid == msglistCurrUId) { + // oops + // restore position 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); - } + // change direction + godown = !godown; + if (godown) break; // down again? we're done + } else { + msglistCurrUId = muid; } } chiroDeletePurgedWithTag(lastDecodedTid); - threadListPositionDirty(); saveThreadListPositions(); } // rescan -- 2.11.4.GIT