int (int lineStartOffset, VisualPosition pos) { if (pos.column == 0) return 0; int x = 0; int offset = lineStartOffset; CharSequence text = myDocument.getCharsNoThreadCheck(); int textLength = myDocument.getTextLength(); IterationState state = new IterationState(this, offset, false); int fontType = state.getMergedAttributes().getFontType(); int spaceSize = getSpaceWidth(fontType); int column = 0; outer: while (column < pos.column) { if (offset >= textLength) break; if (offset >= state.getEndOffset()) { state.advance(); fontType = state.getMergedAttributes().getFontType(); } FoldRegion region = state.getCurrentFold(); if (region != null) { char[] placeholder = region.getPlaceholderText().toCharArray(); for (int j = 0; j < placeholder.length; j++) { x += charWidth(placeholder[j], fontType); column++; if (column >= pos.column) break outer; } offset = region.getEndOffset(); } else { char c = text.charAt(offset); if (c == '\n') { break; } if (c == '\t') { int prevX = x; x = nextTabStop(x); column += (x - prevX) / spaceSize; } else { x += charWidth(c, fontType); column++; } offset++; } } if (column != pos.column) { x += getSpaceWidth(fontType) * (pos.column - column); } return x; }