int (@NotNull String text, int tabSize) { int column = 0; boolean newlineSeen = false; for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); if (c == '\n') newlineSeen = true; else if (c == ' ' || c == '\t') { if (column >= 0) column = nextColumn(column, c, tabSize); } else break; } return newlineSeen ? column : -column - 1; }