Skip to content

Commit fd5a7f4

Browse files
authored
refactor: Make the cursor use the focus manager for tracking the current node. (#9142)
1 parent 02f89d6 commit fd5a7f4

File tree

1 file changed

+4
-18
lines changed

1 file changed

+4
-18
lines changed

core/keyboard_nav/line_cursor.ts

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import {BlockSvg} from '../block_svg.js';
1717
import {Field} from '../field.js';
1818
import {getFocusManager} from '../focus_manager.js';
1919
import type {IFocusableNode} from '../interfaces/i_focusable_node.js';
20-
import {isFocusableNode} from '../interfaces/i_focusable_node.js';
2120
import * as registry from '../registry.js';
2221
import {WorkspaceSvg} from '../workspace_svg.js';
2322
import {Marker} from './marker.js';
@@ -374,17 +373,8 @@ export class LineCursor extends Marker {
374373
*
375374
* @returns The current field, connection, or block the cursor is on.
376375
*/
377-
override getCurNode(): IFocusableNode | null {
378-
// Ensure the current node matches what's currently focused.
379-
const focused = getFocusManager().getFocusedNode();
380-
const block = this.getSourceBlockFromNode(focused);
381-
if (block && block.workspace === this.workspace) {
382-
// If the current focused node corresponds to a block then ensure that it
383-
// belongs to the correct workspace for this cursor.
384-
this.setCurNode(focused);
385-
}
386-
387-
return super.getCurNode();
376+
getCurNode(): IFocusableNode | null {
377+
return getFocusManager().getFocusedNode();
388378
}
389379

390380
/**
@@ -395,12 +385,8 @@ export class LineCursor extends Marker {
395385
*
396386
* @param newNode The new location of the cursor.
397387
*/
398-
override setCurNode(newNode: IFocusableNode | null) {
399-
super.setCurNode(newNode);
400-
401-
if (isFocusableNode(newNode)) {
402-
getFocusManager().focusNode(newNode);
403-
}
388+
setCurNode(newNode: IFocusableNode) {
389+
getFocusManager().focusNode(newNode);
404390

405391
// Try to scroll cursor into view.
406392
if (newNode instanceof BlockSvg) {

0 commit comments

Comments
 (0)