Skip to content

Commit

Permalink
fix: when pasting, expand all pasted contents by default when small
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed Apr 4, 2022
1 parent ad2aa7d commit ec9703c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/lib/components/modes/treemode/TreeMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -749,17 +749,24 @@
function doPaste(clipboardText) {
if (json !== undefined) {
const operations = insert(json, state, selection, clipboardText)
const expandAllRecursive = !isLargeContent(
{ text: clipboardText },
MAX_DOCUMENT_SIZE_EXPAND_ALL
)
debug('paste', { clipboardText, operations, selection })
debug('paste', { clipboardText, operations, selection, expandAllRecursive })
handlePatch(operations)
// expand newly inserted object/array
operations
.filter((operation) => isObjectOrArray(operation.value))
.forEach(async (operation) => {
const path = parseJSONPointerWithArrayIndices(json, operation.path)
handleExpand(path, true, false)
.forEach(async (operation, index) => {
// keep the same behavior as the getDefaultExpand method
if (expandAllRecursive || index === 0) {
const path = parseJSONPointerWithArrayIndices(json, operation.path)
handleExpand(path, true, expandAllRecursive)
}
})
} else {
debug('paste', { clipboardText })
Expand Down

0 comments on commit ec9703c

Please sign in to comment.