Fix remaining tests

This commit is contained in:
Daniel Imms
2019-06-08 17:12:18 -07:00
parent c44524b553
commit 291fc7368d
5 changed files with 19 additions and 12 deletions
+1 -1
View File
@@ -20,7 +20,7 @@ class TestSelectionManager extends SelectionManager {
constructor(
terminal: ITerminal
) {
super(terminal, new MockCharSizeService(10, 10));
super(terminal, new MockCharSizeService(10, 10), new MockBufferService(20, 20));
}
public get model(): SelectionModel { return this._model; }
+4 -2
View File
@@ -13,6 +13,7 @@ import { CellData } from 'common/buffer/BufferLine';
import { IDisposable } from 'xterm';
import { EventEmitter2, IEvent } from 'common/EventEmitter2';
import { ICharSizeService } from 'browser/services/Services';
import { IBufferService } from 'common/services/Services';
/**
* The number of pixels the mouse needs to be above or below the viewport in
@@ -117,12 +118,13 @@ export class SelectionManager implements ISelectionManager {
constructor(
private _terminal: ITerminal,
private _charSizeService: ICharSizeService
private _charSizeService: ICharSizeService,
bufferService: IBufferService
) {
this._initListeners();
this.enable();
this._model = new SelectionModel(_terminal);
this._model = new SelectionModel(_terminal, bufferService);
this._activeSelectionMode = SelectionMode.NORMAL;
}
+7 -4
View File
@@ -8,12 +8,14 @@ import { ITerminal } from './Types';
import { SelectionModel } from './SelectionModel';
import { BufferSet } from './BufferSet';
import { MockTerminal, MockOptionsService, MockBufferService } from './TestUtils.test';
import { IBufferService } from 'common/services/Services';
class TestSelectionModel extends SelectionModel {
constructor(
terminal: ITerminal
terminal: ITerminal,
bufferService: IBufferService
) {
super(terminal);
super(terminal, bufferService);
}
}
@@ -23,13 +25,14 @@ describe('SelectionManager', () => {
beforeEach(() => {
terminal = new MockTerminal();
const bufferService = new MockBufferService(80, 2);
terminal.buffers = new BufferSet(
new MockOptionsService({ scrollback: 10 }),
new MockBufferService(80, 2)
bufferService
);
terminal.buffer = terminal.buffers.active;
model = new TestSelectionModel(terminal);
model = new TestSelectionModel(terminal, bufferService);
});
describe('clearSelection', () => {
+6 -4
View File
@@ -4,6 +4,7 @@
*/
import { ITerminal } from './Types';
import { IBufferService } from 'common/services/Services';
/**
* Represents a selection within the buffer. This model only cares about column
@@ -33,7 +34,8 @@ export class SelectionModel {
public selectionEnd: [number, number];
constructor(
private _terminal: ITerminal
private _terminal: ITerminal,
private _bufferService: IBufferService
) {
this.clearSelection();
}
@@ -69,7 +71,7 @@ export class SelectionModel {
*/
public get finalSelectionEnd(): [number, number] {
if (this.isSelectAllActive) {
return [this._terminal.cols, this._terminal.buffer.ybase + this._terminal.rows - 1];
return [this._bufferService.cols, this._terminal.buffer.ybase + this._bufferService.rows - 1];
}
if (!this.selectionStart) {
@@ -79,8 +81,8 @@ export class SelectionModel {
// Use the selection start + length if the end doesn't exist or they're reversed
if (!this.selectionEnd || this.areSelectionValuesReversed()) {
const startPlusLength = this.selectionStart[0] + this.selectionStartLength;
if (startPlusLength > this._terminal.cols) {
return [startPlusLength % this._terminal.cols, this.selectionStart[1] + Math.floor(startPlusLength / this._terminal.cols)];
if (startPlusLength > this._bufferService.cols) {
return [startPlusLength % this._bufferService.cols, this.selectionStart[1] + Math.floor(startPlusLength / this._bufferService.cols)];
}
return [startPlusLength, this.selectionStart[1]];
}
+1 -1
View File
@@ -643,7 +643,7 @@ export class Terminal extends EventEmitter implements ITerminal, IDisposable, II
this.register(this.addDisposableListener('focus', () => this._renderCoordinator.onFocus()));
this.register(this._renderCoordinator.onDimensionsChange(() => this.viewport.syncScrollArea()));
this.selectionManager = new SelectionManager(this, this._charSizeService);
this.selectionManager = new SelectionManager(this, this._charSizeService, this._bufferService);
this.register(this.selectionManager.onSelectionChange(() => this._onSelectionChange.fire()));
this.register(addDisposableDomListener(this.element, 'mousedown', (e: MouseEvent) => this.selectionManager.onMouseDown(e)));
this.register(this.selectionManager.onRedrawRequest(e => this._renderCoordinator.onSelectionChanged(e.start, e.end, e.columnSelectMode)));