Don't crash when trying to apply lastSelectionEvent selection that is out-of-range (#5644)

* Dumbest possible fix: don't let the `throw` propogate

* Add E2E test

* Fix lint
This commit is contained in:
Frank Noirot
2025-03-05 17:52:48 -05:00
committed by GitHub
parent bcac4d3798
commit e500fad0e1
2 changed files with 53 additions and 5 deletions

View File

@ -96,11 +96,15 @@ export const KclEditorPane = () => {
return
}
editorManager.editorView.dispatch({
selection: lastSelectionEvent.codeMirrorSelection,
annotations: [modelingMachineEvent, Transaction.addToHistory.of(false)],
scrollIntoView: lastSelectionEvent.scrollIntoView,
})
try {
editorManager.editorView.dispatch({
selection: lastSelectionEvent.codeMirrorSelection,
annotations: [modelingMachineEvent, Transaction.addToHistory.of(false)],
scrollIntoView: lastSelectionEvent.scrollIntoView,
})
} catch (e) {
console.error('Error setting selection', e)
}
}, [editorIsMounted, lastSelectionEvent])
const textWrapping = context.textEditor.textWrapping