int (int offset, int lineIndex, boolean softWrapAware, @NotNull CharSequence documentCharSequence) { if (myUseNewRendering) return myView.offsetToLogicalPosition(offset).column; if (myDocument.getTextLength() == 0) return 0; int lineStartOffset = myDocument.getLineStartOffset(lineIndex); if (lineStartOffset == offset) return 0; int lineEndOffset = myDocument.getLineEndOffset(lineIndex); if (lineEndOffset < offset) offset = lineEndOffset; // handling the case when offset is inside non-normalized line terminator int column = EditorUtil.calcColumnNumber(this, documentCharSequence, lineStartOffset, offset); if (softWrapAware) { int line = offsetToLogicalLine(offset); return mySoftWrapModel.adjustLogicalPosition(new LogicalPosition(line, column), offset).column; } else { return column; } }