diff --git a/list-editor/cursor.js b/list-editor/cursor.js index 88252ef..c6cf3d8 100644 --- a/list-editor/cursor.js +++ b/list-editor/cursor.js @@ -40,7 +40,13 @@ function createCursor(start) { cursor = store.nextCursorPosition(cursor, true) }, remove(store) { - store.remove(cursor, 1) + let id = store.currentID(cursor) + let item = store.value(id) + store.remove(cursor) + if (cursor >= store.length()) { + cursor = store.length() - 1 + } + cursor = store.firstSameIndented(cursor, item.idented) }, insertAbove(store, item) { store.insertBefore(store.currentID(cursor), item) diff --git a/list-editor/selection.js b/list-editor/selection.js index d25732e..a39fa2b 100644 --- a/list-editor/selection.js +++ b/list-editor/selection.js @@ -27,7 +27,7 @@ function createSelection() { }, remove(store) { - store.remove(first, last - first) + // store.remove(first, last - first) }, hasSelection() { diff --git a/list-editor/store.js b/list-editor/store.js index 0bb1e87..81e9317 100644 --- a/list-editor/store.js +++ b/list-editor/store.js @@ -220,7 +220,13 @@ function Store(inputData) { } } - function remove(start, len) { + function remove(first) { + let last = lastHigherIndented(first) + idList.splice(first, last-first) + changed = true + } + + function internalRemove(start, len) { idList.splice(start, len) changed = true } @@ -280,7 +286,7 @@ function Store(inputData) { function moveBefore(from, to) { let fromIndex = _.findIndex(idList, (id) => id === from) let item = values[from] - remove(fromIndex, 1) + internalRemove(fromIndex, 1) let result = insertBefore(to, item) changed = true return result @@ -417,6 +423,7 @@ function Store(inputData) { values[item.id] = item }) idList.splice(first, last - first, ...ids) + changed = true } let removeLevel = 9999999999;