fix selection override

This commit is contained in:
Kurt Hutten Irev-Dev
2024-06-28 07:27:28 +10:00
parent 2a5edbec19
commit 68e66e2980
2 changed files with 10 additions and 3 deletions

View File

@ -327,6 +327,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 &&