From 9c13f0e7cd965d2bffce1536849df251d0eee338 Mon Sep 17 00:00:00 2001 From: Grace Date: Wed, 23 Apr 2025 16:26:06 +0100 Subject: [PATCH 1/3] fix: loop cursor when moving to prev node --- core/keyboard_nav/line_cursor.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/core/keyboard_nav/line_cursor.ts b/core/keyboard_nav/line_cursor.ts index b2bda39c739..2025da7bf06 100644 --- a/core/keyboard_nav/line_cursor.ts +++ b/core/keyboard_nav/line_cursor.ts @@ -146,10 +146,12 @@ export class LineCursor extends Marker { if (!curNode) { return null; } - const newNode = this.getPreviousNodeImpl( + const newNode = this.getPreviousNode( curNode, this.validLineNode.bind(this), + true, ); + if (newNode) { this.setCurNode(newNode); } @@ -168,9 +170,10 @@ export class LineCursor extends Marker { if (!curNode) { return null; } - const newNode = this.getPreviousNodeImpl( + const newNode = this.getPreviousNode( curNode, this.validInLineNode.bind(this), + true, ); if (newNode) { From e2fedc1a74bfab33461b4a4e4804cd060d011f7a Mon Sep 17 00:00:00 2001 From: Grace Date: Thu, 24 Apr 2025 10:20:28 +0100 Subject: [PATCH 2/3] chore: add loop tests for LineCursor prev and out --- tests/mocha/cursor_test.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/mocha/cursor_test.js b/tests/mocha/cursor_test.js index 905f48c09ad..853069e7f16 100644 --- a/tests/mocha/cursor_test.js +++ b/tests/mocha/cursor_test.js @@ -125,6 +125,15 @@ suite('Cursor', function () { assert.equal(curNode.getLocation(), this.blocks.A.nextConnection); }); + test('Prev - From first connection loop to last next connection', function () { + const prevConnection = this.blocks.A.previousConnection; + const prevConnectionNode = ASTNode.createConnectionNode(prevConnection); + this.cursor.setCurNode(prevConnectionNode); + this.cursor.prev(); + const curNode = this.cursor.getCurNode(); + assert.equal(curNode.getLocation(), this.blocks.D.nextConnection); + }); + test('Out - From field does not skip over block node', function () { const field = this.blocks.E.inputList[0].fieldRow[0]; const fieldNode = ASTNode.createFieldNode(field); @@ -133,6 +142,15 @@ suite('Cursor', function () { const curNode = this.cursor.getCurNode(); assert.equal(curNode.getLocation(), this.blocks.E); }); + + test('Out - From first connection loop to last next connection', function () { + const prevConnection = this.blocks.A.previousConnection; + const prevConnectionNode = ASTNode.createConnectionNode(prevConnection); + this.cursor.setCurNode(prevConnectionNode); + this.cursor.prev(); + const curNode = this.cursor.getCurNode(); + assert.equal(curNode.getLocation(), this.blocks.D.nextConnection); + }); }); suite('Searching', function () { setup(function () { From 16700624246fccb05b53edd0a6883a9c1b393956 Mon Sep 17 00:00:00 2001 From: Grace Date: Fri, 25 Apr 2025 09:04:04 +0100 Subject: [PATCH 3/3] chore: fix out loop test for line cursor --- tests/mocha/cursor_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/mocha/cursor_test.js b/tests/mocha/cursor_test.js index 853069e7f16..53f0714da11 100644 --- a/tests/mocha/cursor_test.js +++ b/tests/mocha/cursor_test.js @@ -147,7 +147,7 @@ suite('Cursor', function () { const prevConnection = this.blocks.A.previousConnection; const prevConnectionNode = ASTNode.createConnectionNode(prevConnection); this.cursor.setCurNode(prevConnectionNode); - this.cursor.prev(); + this.cursor.out(); const curNode = this.cursor.getCurNode(); assert.equal(curNode.getLocation(), this.blocks.D.nextConnection); });