Remove items below removed item

This commit is contained in:
Peter Stuifzand 2020-10-28 20:12:04 +01:00
parent 5006e1095a
commit 93e10f5272
3 changed files with 17 additions and 4 deletions

View File

@ -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)

View File

@ -27,7 +27,7 @@ function createSelection() {
},
remove(store) {
store.remove(first, last - first)
// store.remove(first, last - first)
},
hasSelection() {

View File

@ -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;