Skip to content

Commit

Permalink
fix: expanded state being reset when updating the contents
Browse files Browse the repository at this point in the history
  • Loading branch information
josdejong committed May 30, 2022
1 parent a3e496a commit 27f61f2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/lib/components/modes/treemode/TreeMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@
const previousSelection = selection
json = updatedJson
state = syncState(json, previousState, [], getDefaultExpand(json), true)
state = syncState(json, previousState, [], getDefaultExpand(json), false)
text = undefined
textIsRepaired = false
selection = clearSelectionWhenNotExisting(selection, json)
Expand Down Expand Up @@ -405,21 +405,21 @@
try {
json = JSON.parse(updatedText)
state = syncState(json, previousState, [], getDefaultExpand(json), true)
state = syncState(json, previousState, [], getDefaultExpand(json), false)
text = updatedText
textIsRepaired = false
selection = clearSelectionWhenNotExisting(selection, json)
} catch (err) {
try {
json = JSON.parse(jsonrepair(updatedText))
state = syncState(json, previousState, [], getDefaultExpand(json), true)
state = syncState(json, previousState, [], getDefaultExpand(json), false)
text = updatedText
textIsRepaired = true
selection = clearSelectionWhenNotExisting(selection, json)
} catch (err) {
// no valid JSON, will show empty document or invalid json
json = undefined
state = createState(json)
state = undefined
text = externalContent.text
textIsRepaired = false
selection = clearSelectionWhenNotExisting(selection, json)
Expand Down Expand Up @@ -829,7 +829,7 @@
if (isEmpty(selection.focusPath)) {
// root selected -> clear complete document
debug('remove', { selection })
debug('remove root', { selection })
const patchResult = null
Expand Down

0 comments on commit 27f61f2

Please sign in to comment.