LineLayout (@NotNull EditorView view, @NotNull List<BidiRun> runs, @Nullable CharSequence text, int line) { if (runs.isEmpty()) return new SingleChunk(null); if (runs.size() == 1) { BidiRun run = runs.get(0); if (run.level == 0 && run.getChunkCount() == 1) { Chunk chunk = run.chunks == null ? new Chunk(0, run.endOffset) : run.chunks.get(0); return new SingleChunk(chunk); } } BidiRun[] runArray = new BidiRun[runs.size()]; int prevColumn = 0; for (int i = 0; i < runs.size(); i++) { BidiRun run = runs.get(i); assert i == 0 || run.startOffset == runs.get(i - 1).endOffset; int startColumn = prevColumn; int endColumn = text == null ? view.getLogicalPositionCache().offsetToLogicalColumn(line, run.endOffset) : LogicalPositionCache.calcColumn(text, run.startOffset, prevColumn, run.endOffset, view.getTabSize()); run.visualStartLogicalColumn = run.isRtl() ? endColumn : startColumn; prevColumn = endColumn; runArray[i] = run; } return new MultiChunk(runArray); }