💄
This commit is contained in:
+7
-4
@@ -408,14 +408,17 @@ export class BufferStringIterator implements IBufferStringIterator {
|
|||||||
private _start: number;
|
private _start: number;
|
||||||
private _end: number;
|
private _end: number;
|
||||||
private _current: number;
|
private _current: number;
|
||||||
|
|
||||||
constructor (private _buffer: IBuffer, private _trimRight: boolean, startIndex?: number, endIndex?: number) {
|
constructor (private _buffer: IBuffer, private _trimRight: boolean, startIndex?: number, endIndex?: number) {
|
||||||
this._start = startIndex || 0;
|
this._start = startIndex || 0;
|
||||||
this._end = endIndex || this._buffer.lines.length;
|
this._end = endIndex || this._buffer.lines.length;
|
||||||
this._current = this._start;
|
this._current = this._start;
|
||||||
}
|
}
|
||||||
|
|
||||||
public hasNext(): boolean {
|
public hasNext(): boolean {
|
||||||
return this._current < this._end;
|
return this._current < this._end;
|
||||||
}
|
}
|
||||||
|
|
||||||
public next(withRanges: boolean = false): string | [{first: number, last: number}, string] {
|
public next(withRanges: boolean = false): string | [{first: number, last: number}, string] {
|
||||||
const range = this._buffer.getWrappedRangeForLine(this._current);
|
const range = this._buffer.getWrappedRangeForLine(this._current);
|
||||||
let result = '';
|
let result = '';
|
||||||
@@ -423,12 +426,12 @@ export class BufferStringIterator implements IBufferStringIterator {
|
|||||||
// TODO: always apply trimRight after fixing #1685
|
// TODO: always apply trimRight after fixing #1685
|
||||||
result += this._buffer.translateBufferLineToString(i, (this._trimRight) ? i === range.last : false);
|
result += this._buffer.translateBufferLineToString(i, (this._trimRight) ? i === range.last : false);
|
||||||
}
|
}
|
||||||
this._current = range.last;
|
this._current = range.last + 1;
|
||||||
this._current++;
|
|
||||||
return (withRanges) ? [range, result] : result;
|
return (withRanges) ? [range, result] : result;
|
||||||
}
|
}
|
||||||
toArray(): string[] {
|
|
||||||
const result: string[] = [];
|
public toArray(): string[] {
|
||||||
|
const result = [];
|
||||||
while (this.hasNext()) {
|
while (this.hasNext()) {
|
||||||
result.push(this.next() as string);
|
result.push(this.next() as string);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -271,7 +271,6 @@ export interface ITerminalOptions extends IPublicTerminalOptions {
|
|||||||
export interface IBufferStringIterator {
|
export interface IBufferStringIterator {
|
||||||
hasNext(): boolean;
|
hasNext(): boolean;
|
||||||
next(withRanges: boolean): string | [{first: number, last: number}, string];
|
next(withRanges: boolean): string | [{first: number, last: number}, string];
|
||||||
toArray(): string[];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IBuffer {
|
export interface IBuffer {
|
||||||
|
|||||||
Reference in New Issue
Block a user