-
Notifications
You must be signed in to change notification settings - Fork 1.8k
CircularList.onInsert/onDelete only fire on reflow currently #2533
Copy link
Copy link
Closed
Labels
Description
They should also fire when the sequences for inserting and deleting lines are triggered:
Lines 921 to 980 in 91d1f97
| /** | |
| * 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:
xterm.js/src/common/CircularList.ts
Lines 154 to 180 in bc9649b
| 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.
Reactions are currently unavailable