Selections bug (#2836)

* fix selection override

* add selection test

* fix playwright tests
This commit is contained in:
Kurt Hutten
2024-06-28 14:40:59 +10:00
committed by GitHub
parent bb9d24f821
commit b5f3a067ee
4 changed files with 127 additions and 14 deletions

View File

@ -326,6 +326,11 @@ export const ModelingMachineProvider = ({
)
updateSceneObjectColors()
// side effect to stop code mirror from updating the same selections again
editorManager.lastSelection = selections.codeBasedSelections
.map(({ range }) => `${range[1]}->${range[1]}`)
.join('&')
return {
selectionRanges: selections,
}

View File

@ -23,7 +23,7 @@ export default class EditorManager {
}
private _lastSelectionEvent: number | null = null
private _lastSelection: string = ''
lastSelection: string = ''
private _lastEvent: { event: string; time: number } | null = null
private _modelingSend: (eventInfo: ModelingMachineEvent) => void = () => {}
@ -199,12 +199,14 @@ export default class EditorManager {
viewUpdate?.state?.selection?.ranges || []
)
if (selString === this._lastSelection) {
if (selString === this.lastSelection) {
// onUpdate is noisy and is fired a lot by extensions
// since we're only interested in selections changes we can ignore most of these.
return
}
this._lastSelection = selString
// note this is also set from the "Set selection" action to stop code mirror from updating selections right after
// selections are made from the scene
this.lastSelection = selString
if (
this._lastSelectionEvent &&