From fe341f0851c6fa7bfe7b7fda30d785c358039720 Mon Sep 17 00:00:00 2001
From: Alexander Rose <alex.rose@rcsb.org>
Date: Thu, 31 Oct 2019 16:46:22 -0700
Subject: [PATCH] fix Bundle.toStructure, #19

---
 src/mol-model/structure/structure/element/bundle.ts | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/mol-model/structure/structure/element/bundle.ts b/src/mol-model/structure/structure/element/bundle.ts
index b22289426..c8e53425b 100644
--- a/src/mol-model/structure/structure/element/bundle.ts
+++ b/src/mol-model/structure/structure/element/bundle.ts
@@ -180,9 +180,10 @@ export namespace Bundle {
                     SortedRanges.forEach(e.ranges, (v, i) => _indices[i] = unit.elements[v])
                     indices = SortedArray.ofSortedArray(_indices)
                 } else {
-                    const rangesSize = SortedRanges.size(e.ranges)
                     SortedRanges.forEach(e.ranges, (v, i) => _indices[i] = unit.elements[v])
-                    SortedRanges.forEach(e.set, (v, i) => _indices[i + rangesSize] = unit.elements[v])
+                    for (let i = 0, il = e.set.length; i < il; ++i) {
+                        _indices[i + rangesSize] = unit.elements[e.set[i]]
+                    }
                     indices = SortedArray.ofUnsortedArray(_indices) // requires sort
                 }
 
-- 
GitLab