import*as Platform from"../platform/platform.js";export class TextCursor{constructor(i){this._lineEndings=i,this._offset=0,this._lineNumber=0,this._columnNumber=0}advance(i){for(this._offset=i;this._lineNumber<this._lineEndings.length&&this._lineEndings[this._lineNumber]<this._offset;)++this._lineNumber;this._columnNumber=this._lineNumber?this._offset-this._lineEndings[this._lineNumber-1]-1:this._offset}offset(){return this._offset}resetTo(i){this._offset=i,this._lineNumber=Platform.ArrayUtilities.lowerBound(this._lineEndings,i,Platform.ArrayUtilities.DEFAULT_COMPARATOR),this._columnNumber=this._lineNumber?this._offset-this._lineEndings[this._lineNumber-1]-1:this._offset}lineNumber(){return this._lineNumber}columnNumber(){return this._columnNumber}}