Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CircularList.onInsert/onDelete only fire on reflow currently #2533

Closed
Tyriar opened this issue Nov 4, 2019 · 1 comment
Closed

CircularList.onInsert/onDelete only fire on reflow currently #2533

Tyriar opened this issue Nov 4, 2019 · 1 comment
Labels

Comments

@Tyriar
Copy link
Member

Tyriar commented Nov 4, 2019

They should also fire when the sequences for inserting and deleting lines are triggered:

/**
* CSI Ps L
* Insert Ps Line(s) (default = 1) (IL).
*/
public insertLines(params: IParams): void {
this._restrictCursor();
let param = params.params[0] || 1;
// make buffer local for faster access
const buffer = this._bufferService.buffer;
if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) {
return;
}
const row: number = buffer.y + buffer.ybase;
const scrollBottomRowsOffset = this._bufferService.rows - 1 - buffer.scrollBottom;
const scrollBottomAbsolute = this._bufferService.rows - 1 + buffer.ybase - scrollBottomRowsOffset + 1;
while (param--) {
// test: echo -e '\e[44m\e[1L\e[0m'
// blankLine(true) - xterm/linux behavior
buffer.lines.splice(scrollBottomAbsolute - 1, 1);
buffer.lines.splice(row, 0, buffer.getBlankLine(this._terminal.eraseAttrData()));
}
this._dirtyRowService.markRangeDirty(buffer.y, buffer.scrollBottom);
buffer.x = 0; // see https://vt100.net/docs/vt220-rm/chapter4.html - vt220 only?
}
/**
* CSI Ps M
* Delete Ps Line(s) (default = 1) (DL).
*/
public deleteLines(params: IParams): void {
this._restrictCursor();
let param = params.params[0] || 1;
// make buffer local for faster access
const buffer = this._bufferService.buffer;
if (buffer.y > buffer.scrollBottom || buffer.y < buffer.scrollTop) {
return;
}
const row: number = buffer.y + buffer.ybase;
let j: number;
j = this._bufferService.rows - 1 - buffer.scrollBottom;
j = this._bufferService.rows - 1 + buffer.ybase - j;
while (param--) {
// test: echo -e '\e[44m\e[1M\e[0m'
// blankLine(true) - xterm/linux behavior
buffer.lines.splice(row, 1);
buffer.lines.splice(j, 0, buffer.getBlankLine(this._terminal.eraseAttrData()));
}
this._dirtyRowService.markRangeDirty(buffer.y, buffer.scrollBottom);
buffer.x = 0; // see https://vt100.net/docs/vt220-rm/chapter4.html - vt220 only?
}

That's done via CircularList.splice which only fires onTrim:

public splice(start: number, deleteCount: number, ...items: T[]): void {
// Delete items
if (deleteCount) {
for (let i = start; i < this._length - deleteCount; i++) {
this._array[this._getCyclicIndex(i)] = this._array[this._getCyclicIndex(i + deleteCount)];
}
this._length -= deleteCount;
}
// Add items
for (let i = this._length - 1; i >= start; i--) {
this._array[this._getCyclicIndex(i + items.length)] = this._array[this._getCyclicIndex(i)];
}
for (let i = 0; i < items.length; i++) {
this._array[this._getCyclicIndex(start + i)] = items[i];
}
// Adjust length as needed
if (this._length + items.length > this._maxLength) {
const countToTrim = (this._length + items.length) - this._maxLength;
this._startIndex += countToTrim;
this._length = this._maxLength;
this.onTrimEmitter.fire(countToTrim);
} else {
this._length += items.length;
}
}

We should write failing test cases where a marker is created, an insert/delete occurs and the marker's line is wrong (before the change) and see if the events fix it.

@Tyriar
Copy link
Member Author

Tyriar commented Dec 19, 2022

This is already done

@Tyriar Tyriar closed this as completed Dec 19, 2022
Tyriar added a commit to Tyriar/xterm.js that referenced this issue Dec 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant