mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Clear selection manager when the terminal switches its buffer set or buffer.
This commit is contained in:
+1
-1
@@ -169,7 +169,7 @@ export interface IBuffer {
|
||||
prevStop(x?: number): number;
|
||||
}
|
||||
|
||||
export interface IBufferSet {
|
||||
export interface IBufferSet extends IEventEmitter {
|
||||
alt: IBuffer;
|
||||
normal: IBuffer;
|
||||
active: IBuffer;
|
||||
|
||||
+21
-5
@@ -119,11 +119,27 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
|
||||
this._mouseMoveListener = event => this._onMouseMove(<MouseEvent>event);
|
||||
this._mouseUpListener = event => this._onMouseUp(<MouseEvent>event);
|
||||
|
||||
// Only adjust the selection on trim, shiftElements is rarely used (only in
|
||||
// reverseIndex) and delete in a splice is only ever used when the same
|
||||
// number of elements was just added. Given this is could actually be
|
||||
// beneficial to leave the selection as is for these cases.
|
||||
this._buffer.lines.on('trim', (amount: number) => this._onTrim(amount));
|
||||
this._updateBufferSetHandlers();
|
||||
this._terminal.on('setup', () => {
|
||||
this._onSetupHandler();
|
||||
});
|
||||
}
|
||||
|
||||
private _onSetupHandler(): void {
|
||||
this.clearSelection();
|
||||
this._updateBufferSetHandlers();
|
||||
}
|
||||
|
||||
private _updateBufferSetHandlers(): void {
|
||||
this._terminal.buffers.on('activate', (buffer: IBuffer) => {
|
||||
this.clearSelection();
|
||||
});
|
||||
// Only adjust the selection on trim, shiftElements is rarely used (only in
|
||||
// reverseIndex) and delete in a splice is only ever used when the same
|
||||
// number of elements was just added. Given this is could actually be
|
||||
// beneficial to leave the selection as is for these cases.
|
||||
this._terminal.buffers.normal.lines.on('trim', (amount: number) => this._onTrim(amount));
|
||||
this._terminal.buffers.alt.lines.on('trim', (amount: number) => this._onTrim(amount));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -292,6 +292,7 @@ export class Terminal extends EventEmitter implements ITerminal, IInputHandlingT
|
||||
|
||||
// Create the terminal's buffers and set the current buffer
|
||||
this.buffers = new BufferSet(this);
|
||||
this.emit('setup');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,7 +37,7 @@ export class MockTerminal implements ITerminal {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
on(event: string, callback: () => void): void {
|
||||
throw new Error('Method not implemented.');
|
||||
/* Simply do nothing */
|
||||
}
|
||||
off(type: string, listener: IListenerType): void {
|
||||
throw new Error('Method not implemented.');
|
||||
|
||||
Reference in New Issue
Block a user