Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 5 additions & 2 deletions core/keyboard_nav/line_cursor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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) {
Expand Down
18 changes: 18 additions & 0 deletions tests/mocha/cursor_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.out();
const curNode = this.cursor.getCurNode();
assert.equal(curNode.getLocation(), this.blocks.D.nextConnection);
});
});
suite('Searching', function () {
setup(function () {
Expand Down