From 8fd30fdb03b5cf953d235c66a708fd09f4bb9c50 Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Wed, 28 Oct 2020 20:56:40 +0100 Subject: [PATCH] Insert new item after closed folds --- list-editor/cursor.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/list-editor/cursor.js b/list-editor/cursor.js index c6cf3d8..78a2f56 100644 --- a/list-editor/cursor.js +++ b/list-editor/cursor.js @@ -46,12 +46,19 @@ function createCursor(start) { if (cursor >= store.length()) { cursor = store.length() - 1 } - cursor = store.firstSameIndented(cursor, item.idented) + cursor = store.firstSameIndented(cursor, item.indented) }, insertAbove(store, item) { store.insertBefore(store.currentID(cursor), item) }, insertBelow(store, item) { + let currentID = store.currentID(cursor) + let currentItem = store.value(currentID) + if (currentItem.fold !== 'open') { + cursor = store.lastHigherIndented(cursor) + item.indented = currentItem.indented + cursor-- + } let id = store.insertAfter(store.currentID(cursor), item) cursor = store.index(id) },