From 10d6d7521a43d42a3decf2eff975495ffd6d74c4 Mon Sep 17 00:00:00 2001 From: Peter Stuifzand Date: Sat, 14 Nov 2020 15:56:22 +0100 Subject: [PATCH] Some cleanup --- editor/src/editor.js | 1 + list-editor/index.js | 5 +++-- list-editor/store.js | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/editor/src/editor.js b/editor/src/editor.js index 796c0f9..a876eff 100644 --- a/editor/src/editor.js +++ b/editor/src/editor.js @@ -107,6 +107,7 @@ function showSearchResults(searchTool, query, input, value, resultType) { function showSearchResultsExtended(element, template, searchTool, query, input, value, resultType, options) { const $lc = $(element) + // FIXME(peter): we should not reload this every time we search return searchTool(query).then(results => { let opt = options || {}; if (opt.showOnlyResults && (query.length === 0 || !results.length)) { diff --git a/list-editor/index.js b/list-editor/index.js index b0fb3de..4083989 100644 --- a/list-editor/index.js +++ b/list-editor/index.js @@ -137,9 +137,10 @@ function editor(root, inputData, options) { startEditing(root, store, cursor) } - function getChildren(id ) { - return store.children(id ) + function getChildren(id) { + return store.children(id) } + function replaceChildren(id, children) { store.replaceChildren(id, children) } diff --git a/list-editor/store.js b/list-editor/store.js index 612c126..fa24be5 100644 --- a/list-editor/store.js +++ b/list-editor/store.js @@ -293,7 +293,7 @@ function Store(inputData) { let fromIndex = index(from) let toIndex = to && to !== 'at-end' ? index(to) : idList.length let n = lastHigherIndented(fromIndex) - fromIndex - if (toIndex >= fromIndex && toIndex < fromIndex + n) return index(from) + if (toIndex >= fromIndex && toIndex < fromIndex + n) return [index(from), n] if (fromIndex < toIndex) { rotate(idList, fromIndex, toIndex, n) changed = true