private static String findUrl(Editor editor, int offset) {
    CharSequence chars = editor.getDocument().getCharsSequence();
    while (offset > 0 && seemsUrlPart(chars.charAt(offset - 1))) offset--;

    Matcher matcher = URLUtil.URL_PATTERN.matcher(chars.subSequence(offset, chars.length()));
    if (matcher.lookingAt()) {
      return matcher.group();
    }
    return null;
  }
private static String findUrl(Editor editor, int offset)