Return undefined if cell or line doesn't exist
This commit is contained in:
@@ -180,14 +180,19 @@ class BufferApiView implements IBufferApi {
|
||||
public get viewportY(): number { return this._buffer.ydisp; }
|
||||
public get baseY(): number { return this._buffer.ybase; }
|
||||
public get length(): number { return this._buffer.lines.length; }
|
||||
public getLine(y: number): IBufferLineApi { return new BufferLineApiView(this._buffer.lines.get(y)); }
|
||||
public getLine(y: number): IBufferLineApi | undefined { return new BufferLineApiView(this._buffer.lines.get(y)); }
|
||||
}
|
||||
|
||||
class BufferLineApiView implements IBufferLineApi {
|
||||
constructor(private _line: IBufferLine) {}
|
||||
|
||||
public get isWrapped(): boolean { return this._line.isWrapped; }
|
||||
public getCell(x: number): IBufferCellApi { return new BufferCellApiView(this._line, x); }
|
||||
public getCell(x: number): IBufferCellApi | undefined {
|
||||
if (x < 0 && x >= this._line.length) {
|
||||
return undefined;
|
||||
}
|
||||
return new BufferCellApiView(this._line, x);
|
||||
}
|
||||
public translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string {
|
||||
return this._line.translateToString(trimRight, startColumn, endColumn);
|
||||
}
|
||||
|
||||
Vendored
+3
-3
@@ -895,11 +895,11 @@ declare module 'xterm' {
|
||||
readonly length: number;
|
||||
|
||||
/**
|
||||
* Gets a line from the buffer.
|
||||
* Gets a line from the buffer, or undefined if the line index does not exist.
|
||||
*
|
||||
* @param y The line index to get.
|
||||
*/
|
||||
getLine(y: number): IBufferLine;
|
||||
getLine(y: number): IBufferLine | undefined;
|
||||
}
|
||||
|
||||
interface IBufferLine {
|
||||
@@ -909,7 +909,7 @@ declare module 'xterm' {
|
||||
readonly isWrapped: boolean;
|
||||
|
||||
/**
|
||||
* Gets a cell from the line.
|
||||
* Gets a cell from the line, or undefined if the line index does not exist.
|
||||
*
|
||||
* @param x The character index to get.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user