Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 9 additions & 15 deletions core/keyboard_nav/line_cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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.
*
Expand Down