/// <summary> /// Calculate tab offsets by going up /// </summary> private void CalculateTabOffsetUp(ITextSnapshotLine curLine, int colNumber, ColumnSizeInfo colTabOffset) { int curLineNumber = curLine.LineNumber - 1; ITextSnapshot textSnapshot = _textView.TextSnapshot; ElasticTabstopsLine elasticLine = _elasticTabstopsLinesCache[curLine.LineNumber]; bool isLastColumnInLine = elasticLine.IsLastColumnInLine(colNumber); while (curLineNumber >= 0) { ITextSnapshotLine upLine = textSnapshot.GetLineFromLineNumber(curLineNumber); ElasticTabstopsLine upElasticLine = GetElasticTabstopsLine(upLine); if (upElasticLine.IsLastColumnInLine(colNumber) != isLastColumnInLine) { break; } ElasticTabstopsColumn upColumn = upElasticLine.GetColumnOrDefault(colNumber); if (upColumn == null) { break; } upColumn.TabOffset = colTabOffset; ShrinkTabOffset(upElasticLine, colNumber); curLineNumber--; } }
/// <summary> /// Calculate tab offsets by going down /// </summary> private void CalculateTabOffsetDown(ITextSnapshotLine curLine, int colNumber, ColumnSizeInfo colTabOffset) { int curLineNumber = curLine.LineNumber + 1; ITextSnapshot textSnapshot = _textView.TextSnapshot; ElasticTabstopsLine elasticLine = _elasticTabstopsLinesCache[curLine.LineNumber]; bool isLastColumnInLine = elasticLine.IsLastColumnInLine(colNumber); while (curLineNumber < textSnapshot.LineCount) { ITextSnapshotLine downLine = textSnapshot.GetLineFromLineNumber(curLineNumber); ElasticTabstopsLine downElasticLine = GetElasticTabstopsLine(downLine); if (downElasticLine.IsLastColumnInLine(colNumber) != isLastColumnInLine) { break; } ElasticTabstopsColumn downColumn = downElasticLine.GetColumnOrDefault(colNumber); if (downColumn == null) { break; } downColumn.TabOffset = colTabOffset; ShrinkTabOffset(downElasticLine, colNumber); curLineNumber++; } }