@Override
 public int calcColumnNumber(
     @NotNull final CharSequence text, final int start, final int offset, final int tabSize) {
   int hostStart = myDocumentWindow.injectedToHost(start);
   int hostOffset = myDocumentWindow.injectedToHost(offset);
   return myDelegate.calcColumnNumber(
       myDelegate.getDocument().getText(), hostStart, hostOffset, tabSize);
 }
  @NotNull
  public LogicalPosition injectedToHost(@NotNull LogicalPosition pos) {
    assert isValid();
    // beware the virtual space
    int column = pos.column;
    int lineStartOffset = myDocumentWindow.getLineStartOffset(pos.line);
    int lineEndOffset = myDocumentWindow.getLineEndOffset(pos.line);
    if (column > lineEndOffset - lineStartOffset) {
      // in virtual space, calculate the host pos as an offset from the line end
      int delta = column - (lineEndOffset - lineStartOffset);

      int baseOffsetInHost = myDocumentWindow.injectedToHost(lineEndOffset);
      LogicalPosition lineStartPosInHost = myDelegate.offsetToLogicalPosition(baseOffsetInHost);
      return new LogicalPosition(lineStartPosInHost.line, lineStartPosInHost.column + delta);
    } else {
      int offset = lineStartOffset + column;
      int hostOffset = getDocument().injectedToHost(offset);
      int hostLineNumber = getDocument().getDelegate().getLineNumber(hostOffset);
      int hostLineStart = getDocument().getDelegate().getLineStartOffset(hostLineNumber);

      return new LogicalPosition(hostLineNumber, hostOffset - hostLineStart);
    }
  }
 @Override
 public int calcColumnNumber(int offset, int lineIndex) {
   return myDelegate.calcColumnNumber(
       myDocumentWindow.injectedToHost(offset), myDocumentWindow.injectedToHostLine(lineIndex));
 }
 @Override
 public void repaint(final int startOffset, final int endOffset) {
   assert isValid();
   myDelegate.repaint(
       myDocumentWindow.injectedToHost(startOffset), myDocumentWindow.injectedToHost(endOffset));
 }