Skip to content

Commit 4c7d6a6

Browse files
fix: don't keep cursor on disposed blocks (#271)
* fix: don't keep cursor on disposed blocks Perhaps this should be cleared earlier, but this scenario happens in MakeCode when switching back to Blocks mode from JavaScript. One approach to #146 * chore: improve comments and naming
1 parent c5b27ed commit 4c7d6a6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/navigation.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,10 @@ export class Navigation {
511511
return;
512512
}
513513

514-
if (cursor.getCurNode() && keepPosition) {
515-
// Retain the cursor's previous position since it's set.
514+
const disposed = cursor.getCurNode()?.getSourceBlock()?.disposed;
515+
if (cursor.getCurNode() && !disposed && keepPosition) {
516+
// Retain the cursor's previous position since it's set, but only if not
517+
// disposed (which can happen when blocks are reloaded).
516518
return;
517519
}
518520
const wsCoordinates = new Blockly.utils.Coordinate(

0 commit comments

Comments
 (0)