@ApiStatus.Experimental
  static @NotNull ModCommand moveCaretAfter(@NotNull ModCommand command, @NotNull PsiFile file, int offset, boolean leanRight) {
    VirtualFile virtualFile = file.getVirtualFile();
    ModCommand finalCommand = nop();
    for (ModCommand sub : command.unpack()) {
      if (sub instanceof ModUpdateFileText updateFileText && updateFileText.file().equals(virtualFile)) {
        offset = updateFileText.translateOffset(offset, leanRight);
      }
      if (sub instanceof ModDeleteFile deleteFile && deleteFile.file().equals(virtualFile)) {
        // Navigation is useless: we are removing the target file
        return command;
      }
      if (!(sub instanceof ModNavigate)) {
        finalCommand = finalCommand.andThen(sub);
      }
    }
    return finalCommand.andThen(new ModNavigate(virtualFile, offset, offset, offset));
  }
@ApiStatus.Experimental
  static @NotNull ModCommand moveCaretAfter(@NotNull ModCommand command, @NotNull PsiFile file, int offset, boolean leanRight)