public ColumnNumberWithOffset GetColumn(TextLocation location)
        {
            var lines = Lines;

            var currentLineIndex   = location.Line - 1;
            var currentColumnIndex = location.Column - 1;

            var currentLine = lines[currentLineIndex];

            var sum = 0;
            var i   = 0;

            while (currentLine.Length > i && sum <= currentColumnIndex)
            {
                sum += currentLine[i];
                i++;
            }

            var column = new ColumnNumberWithOffset
            {
                ColumnNumber = i - 1,
                OffsetInLine = sum,
                Length       = currentLine[i - 1]
            };

            return(column);
        }
        public override int GetFirstInterestedOffset(int startOffset)
        {
            if (Lines == null)
            {
                return(startOffset);
            }

            var location = CurrentContext.Document.GetLocation(startOffset);

            var columnNumberWithOffset = GetColumn(location);
            var locationLine           = location.Line;

            if (columnNumberWithOffset.ColumnNumber == ColumnWidth.Length - 1)
            {
                if (Lines.Length == locationLine)
                {
                    return(CurrentContext.VisualLine.LastDocumentLine.EndOffset);
                }

                columnNumberWithOffset = new ColumnNumberWithOffset
                {
                    ColumnNumber = 0,
                    OffsetInLine = Lines[locationLine][0]
                };

                locationLine++;
            }

            var curCellWidth = this._freezeInProgress &&
                               _activeRowIndex == locationLine - 1 &&
                               columnNumberWithOffset.ColumnNumber == _activeColumnIndex
                ?
                               _activeCellRealLength : ColumnWidth[columnNumberWithOffset.ColumnNumber];

            _tabWidth = curCellWidth - Lines[locationLine - 1][columnNumberWithOffset.ColumnNumber];

            try
            {
                return(CurrentContext.Document.GetOffset(new TextLocation(locationLine, columnNumberWithOffset.OffsetInLine)));
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Failed to get first interested offset");
                return(startOffset);
            }
        }