This commit is contained in:
Daniel Imms
2018-09-13 19:44:02 -07:00
parent 7401567856
commit cd2ac929c3
2 changed files with 7 additions and 5 deletions
+7 -4
View File
@@ -408,14 +408,17 @@ export class BufferStringIterator implements IBufferStringIterator {
private _start: number;
private _end: number;
private _current: number;
constructor (private _buffer: IBuffer, private _trimRight: boolean, startIndex?: number, endIndex?: number) {
this._start = startIndex || 0;
this._end = endIndex || this._buffer.lines.length;
this._current = this._start;
}
public hasNext(): boolean {
return this._current < this._end;
}
public next(withRanges: boolean = false): string | [{first: number, last: number}, string] {
const range = this._buffer.getWrappedRangeForLine(this._current);
let result = '';
@@ -423,12 +426,12 @@ export class BufferStringIterator implements IBufferStringIterator {
// TODO: always apply trimRight after fixing #1685
result += this._buffer.translateBufferLineToString(i, (this._trimRight) ? i === range.last : false);
}
this._current = range.last;
this._current++;
this._current = range.last + 1;
return (withRanges) ? [range, result] : result;
}
toArray(): string[] {
const result: string[] = [];
public toArray(): string[] {
const result = [];
while (this.hasNext()) {
result.push(this.next() as string);
}
-1
View File
@@ -271,7 +271,6 @@ export interface ITerminalOptions extends IPublicTerminalOptions {
export interface IBufferStringIterator {
hasNext(): boolean;
next(withRanges: boolean): string | [{first: number, last: number}, string];
toArray(): string[];
}
export interface IBuffer {