private static void delete(@NotNull Editor editor, @NotNull Caret caret, int start, int end) {
    CopyPasteManager.getInstance().stopKillRings();
    editor.getDocument().deleteString(start, end);

    // in case the caret was in the virtual space, we force it to go back to the real offset
    caret.moveToOffset(start);
  }
private static void delete(@NotNull Editor editor, @NotNull Caret caret, int start, int end)