Skip to content

Commit cbdd0b2

Browse files
feat: return cursor to marked location when exiting toolbox (#210)
* feat: return cursor to marked location when exiting toolbox * chore: update documentation
1 parent 7dcbbbe commit cbdd0b2

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/navigation.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -538,10 +538,13 @@ export class Navigation {
538538
}
539539

540540
/**
541-
* Moves the cursor to the top connection point on on the first top block.
542-
* If the workspace is empty, moves the cursor to the default location on
543-
* the workspace.
544-
*
541+
* Sets the cursor location when focusing the workspace.
542+
* Tries the following, in order, stopping after the first success:
543+
* - Resume editing by putting the cursor at the marker location, if any.
544+
* - Resume editing by returning the cursor to its previous location, if any.
545+
* - Move the cursor to the top connection point on on the first top block.
546+
* - Move the cursor to the default location on the workspace.
547+
*
545548
* @param workspace The main Blockly workspace.
546549
* @param keepPosition Whether to retain the cursor's previous position.
547550
*/
@@ -554,6 +557,13 @@ export class Navigation {
554557
if (!cursor) {
555558
return;
556559
}
560+
561+
if (this.markedNode) {
562+
cursor.setCurNode(this.markedNode);
563+
this.removeMark(workspace);
564+
return;
565+
}
566+
557567
if (cursor.getCurNode() && keepPosition) {
558568
// Retain the cursor's previous position since it's set.
559569
return;

0 commit comments

Comments
 (0)