From a307607139a3db3511a91f016cd121ed9b1aaab2 Mon Sep 17 00:00:00 2001
From: Maximilian Giller <m.giller@tu-bs.de>
Date: Mon, 13 Jun 2022 12:49:35 +0200
Subject: [PATCH] Selecting correct history point when editing

---
 src/editor/js/components/historynavigator.tsx | 5 +++++
 src/editor/js/structures/manageddata.ts       | 9 ++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/src/editor/js/components/historynavigator.tsx b/src/editor/js/components/historynavigator.tsx
index 4d583fc..4eb3616 100644
--- a/src/editor/js/components/historynavigator.tsx
+++ b/src/editor/js/components/historynavigator.tsx
@@ -65,6 +65,11 @@ export class HistoryNavigator extends React.Component<propTypes> {
                                   <option
                                       key={savepoint.id}
                                       value={savepoint.id}
+                                      selected={
+                                          savepoint.id ===
+                                          this.props.historyObject
+                                              .currentSavePoint.id
+                                      }
                                   >
                                       {savepoint.description}
                                   </option>
diff --git a/src/editor/js/structures/manageddata.ts b/src/editor/js/structures/manageddata.ts
index c40ada5..5585d42 100644
--- a/src/editor/js/structures/manageddata.ts
+++ b/src/editor/js/structures/manageddata.ts
@@ -34,6 +34,13 @@ export default class ManagedData extends SerializableItem {
         this.storeCurrentData("Initial state", false);
     }
 
+    /**
+     * @returns SavePoint of current history position. Gives access to meta data of current data.
+     */
+    public get currentSavePoint(): SavePoint {
+        return this.history[this.historyPosition];
+    }
+
     /**
      * If the data has unsaved changes, this will subscribe to the tab-closing event to warn about losing unsaved changes before closing.
      * @private
@@ -144,7 +151,7 @@ export default class ManagedData extends SerializableItem {
                 return this.setHistoryPosition(i);
             }
         }
-        return false;   // Not found
+        return false; // Not found
     }
 
     /**
-- 
GitLab