change to max/min
This commit is contained in:
@@ -25,6 +25,8 @@ function getCursor(term: TestTerminal): number[] {
|
||||
describe('InputHandler', () => {
|
||||
describe('save and restore cursor', () => {
|
||||
const terminal = new MockInputHandlingTerminal();
|
||||
terminal.cols = 80;
|
||||
terminal.rows = 30;
|
||||
terminal.buffer.x = 1;
|
||||
terminal.buffer.y = 2;
|
||||
terminal.buffer.ybase = 0;
|
||||
|
||||
+4
-19
@@ -584,25 +584,10 @@ export class InputHandler extends Disposable implements IInputHandler {
|
||||
* Restrict cursor to viewport size / scroll margin (origin mode).
|
||||
*/
|
||||
private _restrictCursor(): void {
|
||||
// cols
|
||||
if (this._terminal.buffer.x < 0) {
|
||||
this._terminal.buffer.x = 0;
|
||||
} else if (this._terminal.buffer.x >= this._terminal.cols) {
|
||||
this._terminal.buffer.x = this._terminal.cols - 1;
|
||||
}
|
||||
// rows
|
||||
if (this._terminal.buffer.y < 0) {
|
||||
this._terminal.buffer.y = 0;
|
||||
} else if (this._terminal.buffer.y >= this._terminal.rows) {
|
||||
this._terminal.buffer.y = this._terminal.rows - 1;
|
||||
}
|
||||
if (this._terminal.originMode) {
|
||||
if (this._terminal.buffer.y < this._terminal.buffer.scrollTop) {
|
||||
this._terminal.buffer.y = this._terminal.buffer.scrollTop;
|
||||
} else if (this._terminal.buffer.y > this._terminal.buffer.scrollBottom) {
|
||||
this._terminal.buffer.y = this._terminal.buffer.scrollBottom;
|
||||
}
|
||||
}
|
||||
this._terminal.buffer.x = Math.min(this._terminal.cols - 1, Math.max(0, this._terminal.buffer.x));
|
||||
this._terminal.buffer.y = this._terminal.originMode
|
||||
? Math.min(this._terminal.buffer.scrollBottom, Math.max(this._terminal.buffer.scrollTop, this._terminal.buffer.y))
|
||||
: Math.min(this._terminal.rows - 1, Math.max(0, this._terminal.buffer.y));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user