public static @Nullable VcsSelection getSelection(@NotNull AnAction action, @NotNull AnActionEvent e) {
    Editor editor = e.getData(CommonDataKeys.EDITOR);
    if (editor == null) return null;

    VcsSelection atCaret = e.getUpdateSession()
      .compute(action, "getSelection", ActionUpdateThread.EDT, () -> {
        SelectionModel selectionModel = editor.getSelectionModel();
        if (selectionModel.hasSelection() && !EditorUtil.contextMenuInvokedOutsideOfSelection(e)) {
          return new VcsSelection(editor.getDocument(),
                                  new TextRange(selectionModel.getSelectionStart(), selectionModel.getSelectionEnd()),
                                  VcsBundle.message("action.name.show.history.for.selection"));
        }
        return null;
      });
    if (atCaret != null) return atCaret;

    VcsSelection vcsSelection = getSelectionFromExtensions(e.getDataContext());
    if (vcsSelection != null) return vcsSelection;

    Caret caret = editor.getCaretModel().getPrimaryCaret();
    return new VcsSelection(editor.getDocument(),
                            new TextRange(caret.getOffset(), caret.getOffset()),
                            VcsBundle.message("action.name.show.history.for.selection"));
  }
public static @Nullable VcsSelection getSelection(@NotNull AnAction action, @NotNull AnActionEvent e)