mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Fix moveToCell when target is beyond buffer
This commit is contained in:
@@ -23,14 +23,14 @@ describe('MoveToCell', () => {
|
||||
assert.equal(moveToCellSequence(4, 3, bufferService, false), '\x1b[C');
|
||||
});
|
||||
it('should ignore the Y value', () => {
|
||||
assert.equal(moveToCellSequence(1, 1, bufferService, false), '\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D');
|
||||
assert.equal(moveToCellSequence(1, 1, bufferService, false), '\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D');
|
||||
assert.equal(moveToCellSequence(1, 2, bufferService, false), '\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D');
|
||||
assert.equal(moveToCellSequence(1, 3, bufferService, false), '\u001b[D\u001b[D');
|
||||
assert.equal(moveToCellSequence(1, 4, bufferService, false), '\u001b[C\u001b[C\u001b[C');
|
||||
assert.equal(moveToCellSequence(1, 5, bufferService, false), '\u001b[C\u001b[C\u001b[C');
|
||||
});
|
||||
it('should use the correct character for application cursor', () => {
|
||||
assert.equal(moveToCellSequence(2, 1, bufferService, false), '\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D');
|
||||
assert.equal(moveToCellSequence(2, 1, bufferService, false), '\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D\u001b[D');
|
||||
assert.equal(moveToCellSequence(2, 1, bufferService, true), '\u001bOD\u001bOD\u001bOD\u001bOD\u001bOD\u001bOD');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -37,7 +37,7 @@ export function moveToCellSequence(targetX: number, targetY: number, bufferServi
|
||||
}
|
||||
direction = startY > targetY ? Direction.LEFT : Direction.RIGHT;
|
||||
return repeat(colsFromRowEnd(startY > targetY ? targetX : startX, bufferService), sequence(direction, applicationCursor))
|
||||
+ repeat((Math.abs(wrappedRowsForRow(bufferService, startY) - wrappedRowsForRow(bufferService, targetY)) - 1 ) * bufferService.cols, sequence(direction, applicationCursor))
|
||||
+ repeat((Math.abs(startY - targetY) - 1 ) * bufferService.cols, sequence(direction, applicationCursor))
|
||||
+ repeat(colsFromRowBeginning(startY > targetY ? startX : targetX, bufferService), sequence(direction, applicationCursor));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user