From 4a2e93e265256ed89694a6ec140b353400fe4a0b Mon Sep 17 00:00:00 2001
From: dsehnal <david.sehnal@gmail.com>
Date: Tue, 21 Sep 2021 10:15:29 +0200
Subject: [PATCH] fix applyMarkerAction edge case

---
 src/mol-util/marker-action.ts | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/mol-util/marker-action.ts b/src/mol-util/marker-action.ts
index 53bcd5e4f..7ebe4f7b8 100644
--- a/src/mol-util/marker-action.ts
+++ b/src/mol-util/marker-action.ts
@@ -105,8 +105,13 @@ export function applyMarkerAction(array: Uint8Array, set: OrderedSet, action: Ma
             applyMarkerActionAtPosition(array, i, action);
         }
 
-        for (let i = backStart; i < backEnd; ++i) {
-            applyMarkerActionAtPosition(array, i, action);
+        // to prevent applying "toggle" twice check for edge case where
+        // viewEnd <= viewStart, which resolves to the "front" and "back"
+        // intervals being the same range
+        if (frontStart !== backStart) {
+            for (let i = backStart; i < backEnd; ++i) {
+                applyMarkerActionAtPosition(array, i, action);
+            }
         }
     } else {
         switch (action) {
-- 
GitLab