From fd5a7f4a1822908f160532917773255fcb5d3704 Mon Sep 17 00:00:00 2001 From: Aaron Dodson Date: Fri, 13 Jun 2025 12:05:00 -0700 Subject: [PATCH] refactor: Make the cursor use the focus manager for tracking the current node. (#9142) --- core/keyboard_nav/line_cursor.ts | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/core/keyboard_nav/line_cursor.ts b/core/keyboard_nav/line_cursor.ts index 85c0f414a..89668dedb 100644 --- a/core/keyboard_nav/line_cursor.ts +++ b/core/keyboard_nav/line_cursor.ts @@ -17,7 +17,6 @@ import {BlockSvg} from '../block_svg.js'; import {Field} from '../field.js'; import {getFocusManager} from '../focus_manager.js'; import type {IFocusableNode} from '../interfaces/i_focusable_node.js'; -import {isFocusableNode} from '../interfaces/i_focusable_node.js'; import * as registry from '../registry.js'; import {WorkspaceSvg} from '../workspace_svg.js'; import {Marker} from './marker.js'; @@ -374,17 +373,8 @@ export class LineCursor extends Marker { * * @returns The current field, connection, or block the cursor is on. */ - override getCurNode(): IFocusableNode | null { - // 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(); + getCurNode(): IFocusableNode | null { + return getFocusManager().getFocusedNode(); } /** @@ -395,12 +385,8 @@ export class LineCursor extends Marker { * * @param newNode The new location of the cursor. */ - override setCurNode(newNode: IFocusableNode | null) { - super.setCurNode(newNode); - - if (isFocusableNode(newNode)) { - getFocusManager().focusNode(newNode); - } + setCurNode(newNode: IFocusableNode) { + getFocusManager().focusNode(newNode); // Try to scroll cursor into view. if (newNode instanceof BlockSvg) {