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;
|
prevStop(x?: number): number;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IBufferSet {
|
export interface IBufferSet extends IEventEmitter {
|
||||||
alt: IBuffer;
|
alt: IBuffer;
|
||||||
normal: IBuffer;
|
normal: IBuffer;
|
||||||
active: IBuffer;
|
active: IBuffer;
|
||||||
|
|||||||
+21
-5
@@ -119,11 +119,27 @@ export class SelectionManager extends EventEmitter implements ISelectionManager
|
|||||||
this._mouseMoveListener = event => this._onMouseMove(<MouseEvent>event);
|
this._mouseMoveListener = event => this._onMouseMove(<MouseEvent>event);
|
||||||
this._mouseUpListener = event => this._onMouseUp(<MouseEvent>event);
|
this._mouseUpListener = event => this._onMouseUp(<MouseEvent>event);
|
||||||
|
|
||||||
// Only adjust the selection on trim, shiftElements is rarely used (only in
|
this._updateBufferSetHandlers();
|
||||||
// reverseIndex) and delete in a splice is only ever used when the same
|
this._terminal.on('setup', () => {
|
||||||
// number of elements was just added. Given this is could actually be
|
this._onSetupHandler();
|
||||||
// beneficial to leave the selection as is for these cases.
|
});
|
||||||
this._buffer.lines.on('trim', (amount: number) => this._onTrim(amount));
|
}
|
||||||
|
|
||||||
|
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
|
// Create the terminal's buffers and set the current buffer
|
||||||
this.buffers = new BufferSet(this);
|
this.buffers = new BufferSet(this);
|
||||||
|
this.emit('setup');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ export class MockTerminal implements ITerminal {
|
|||||||
throw new Error('Method not implemented.');
|
throw new Error('Method not implemented.');
|
||||||
}
|
}
|
||||||
on(event: string, callback: () => void): void {
|
on(event: string, callback: () => void): void {
|
||||||
throw new Error('Method not implemented.');
|
/* Simply do nothing */
|
||||||
}
|
}
|
||||||
off(type: string, listener: IListenerType): void {
|
off(type: string, listener: IListenerType): void {
|
||||||
throw new Error('Method not implemented.');
|
throw new Error('Method not implemented.');
|
||||||
|
|||||||
Reference in New Issue
Block a user