Skip to content

Commit

Permalink
fix: #312 "Show me" button throwing an error when no position was pro…
Browse files Browse the repository at this point in the history
…vided in the error message
  • Loading branch information
josdejong committed Sep 20, 2023
1 parent c1c682c commit d839e95
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/lib/components/modals/repair/JSONRepairComponent.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@
}
function goToError() {
if (domTextArea && error && error.position != null) {
domTextArea.setSelectionRange(error.position, error.position)
if (domTextArea && error) {
const position = error.position != null ? error.position : 0
domTextArea.setSelectionRange(position, position)
setTimeout(() => {
domTextArea.focus()
})
Expand Down
4 changes: 3 additions & 1 deletion src/lib/components/modes/textmode/TextMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -475,11 +475,13 @@
debug('select parse error', parseError)
const richParseError = toRichParseError(parseError, false)
const from = richParseError.from != null ? richParseError.from : 0
const to = richParseError.to != null ? richParseError.to : 0
// we take "to" as head, not as anchor, because the scrollIntoView will
// move to the head, and when a large whole object is selected as a whole,
// we want to scroll to the start of the object and not the end
setSelection(richParseError.from, richParseError.to)
setSelection(from, to)
focus()
}
Expand Down

0 comments on commit d839e95

Please sign in to comment.