private static @Nullable String findUrlAtCaret(@NotNull AnActionEvent e) {
    Editor editor = e.getData(CommonDataKeys.EDITOR);
    if (editor == null) return null;

    int offset = editor.getCaretModel().getOffset();
    String url = findUrl(editor, offset);
    if (url != null) return url;

    int expectedCaretOffset = ((EditorEx)editor).getExpectedCaretOffset();
    return expectedCaretOffset == offset ? null : findUrl(editor, expectedCaretOffset);
  }
private static @Nullable String findUrlAtCaret(@NotNull AnActionEvent e)