int (@NotNull LogicalPosition pos, boolean softWrapAware) { if (myUseNewRendering) return myView.logicalPositionToOffset(pos); if (softWrapAware) { return mySoftWrapModel.logicalPositionToOffset(pos); } assertReadAccess(); if (myDocument.getLineCount() == 0) return 0; if (pos.line < 0) throw new IndexOutOfBoundsException("Wrong line: " + pos.line); if (pos.column < 0) throw new IndexOutOfBoundsException("Wrong column:" + pos.column); if (pos.line >= myDocument.getLineCount()) { return myDocument.getTextLength(); } int start = myDocument.getLineStartOffset(pos.line); if (pos.column == 0) return start; int end = myDocument.getLineEndOffset(pos.line); int x = getDocument().getLineNumber(start) == 0 ? getPrefixTextWidthInPixels() : 0; int result = EditorUtil.calcSoftWrapUnawareOffset(this, myDocument.getImmutableCharSequence(), start, end, pos.column, EditorUtil.getTabSize(this), x, new int[]{0}, null); if (result >= 0) { return result; } return end; }