Переглянути джерело

mol-plugin: structure selection fix

David Sehnal 6 роки тому
батько
коміт
c87af1708d
1 змінених файлів з 9 додано та 4 видалено
  1. 9 4
      src/mol-plugin/util/structure-element-selection.ts

+ 9 - 4
src/mol-plugin/util/structure-element-selection.ts

@@ -77,12 +77,17 @@ class StructureElementSelectionManager {
         }
         if (!e) return;
 
-        const predIdx = OrderedSet.findPredecessorIndex(e.indices, OrderedSet.min(xs.indices));
+        let predIdx = OrderedSet.findPredecessorIndex(e.indices, OrderedSet.min(xs.indices));
         if (predIdx === 0) return;
 
-        const fst = predIdx < OrderedSet.size(e.indices)
-            ? OrderedSet.getAt(e.indices, predIdx)
-            : OrderedSet.getAt(e.indices, predIdx - 1) + 1 as StructureElement.UnitIndex;
+        let fst;
+
+        if (predIdx < OrderedSet.size(e.indices)) {
+            fst = OrderedSet.getAt(e.indices, predIdx)
+            if (fst > OrderedSet.min(xs.indices)) fst = OrderedSet.getAt(e.indices, predIdx - 1) + 1 as StructureElement.UnitIndex;
+        } else {
+            fst = OrderedSet.getAt(e.indices, predIdx - 1) + 1 as StructureElement.UnitIndex;
+        }
 
         return StructureElement.Loci(entry.selection.structure, [{
             unit: e.unit,