diff --git a/extensions/emmet/src/bufferStream.ts b/extensions/emmet/src/bufferStream.ts index 152724c2039..6f71b0909c1 100644 --- a/extensions/emmet/src/bufferStream.ts +++ b/extensions/emmet/src/bufferStream.ts @@ -17,6 +17,7 @@ export class DocumentStreamReader { private document: TextDocument; private start: Position; private _eof: Position; + private _sof: Position; public pos: Position; private _eol: string; @@ -24,10 +25,18 @@ export class DocumentStreamReader { this.document = document; this.start = this.pos = pos ? pos : new Position(0, 0); + this._sof = limit ? limit.start : new Position(0, 0); this._eof = limit ? limit.end : new Position(this.document.lineCount - 1, this._lineLength(this.document.lineCount - 1)); this._eol = this.document.eol === EndOfLine.LF ? '\n' : '\r\n'; } + /** + * Returns true only if the stream is at the start of the file. + */ + sof(): boolean { + return this.pos.isBeforeOrEqual(this._sof); + } + /** * Returns true only if the stream is at the end of the file. */