diff --git a/core/keyboard_nav/line_cursor.ts b/core/keyboard_nav/line_cursor.ts index 71c61b4f3e4..9d83f6554d3 100644 --- a/core/keyboard_nav/line_cursor.ts +++ b/core/keyboard_nav/line_cursor.ts @@ -374,7 +374,15 @@ export class LineCursor extends Marker { * @returns The current field, connection, or block the cursor is on. */ override getCurNode(): IFocusableNode | null { - this.updateCurNodeFromFocus(); + // Ensure the current node matches what's currently focused. + const focused = getFocusManager().getFocusedNode(); + const block = this.getSourceBlockFromNode(focused); + if (!block || block.workspace === this.workspace) { + // If the current focused node corresponds to a block then ensure that it + // belongs to the correct workspace for this cursor. + this.setCurNode(focused); + } + return super.getCurNode(); } @@ -401,20 +409,6 @@ export class LineCursor extends Marker { } } - /** - * Updates the current node to match what's currently focused. - */ - private updateCurNodeFromFocus() { - const focused = getFocusManager().getFocusedNode(); - - if (focused instanceof BlockSvg) { - const block: BlockSvg | null = focused; - if (block && block.workspace === this.workspace) { - this.setCurNode(block); - } - } - } - /** * Get the first navigable node on the workspace, or null if none exist. *