From 7535cb2cd8df0e3b34ec405c5b019dea5f1f75ad Mon Sep 17 00:00:00 2001 From: ssshooter Date: Sat, 7 Sep 2024 18:23:50 +0800 Subject: [PATCH] fix: catch error of node not found while undo fix #274 --- src/plugin/operationHistory.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/plugin/operationHistory.ts b/src/plugin/operationHistory.ts index 042da728..2c66b38d 100644 --- a/src/plugin/operationHistory.ts +++ b/src/plugin/operationHistory.ts @@ -59,9 +59,14 @@ export default function (mei: MindElixirInstance) { const h = history[currentIndex] current = h.prev mei.refresh(h.prev) - if (h.currentObject.type === 'node') mei.selectNode(findEle(h.currentObject.value)) - else if (h.currentObject.type === 'nodes') mei.selectNodes(h.currentObject.value.map(id => findEle(id))) - currentIndex-- + try { + if (h.currentObject.type === 'node') mei.selectNode(findEle(h.currentObject.value)) + else if (h.currentObject.type === 'nodes') mei.selectNodes(h.currentObject.value.map(id => findEle(id))) + } catch (e) { + // undo add node cause node not found + } finally { + currentIndex-- + } // console.log('current', current) } }