private static @NotNull List<Pair<Integer, Boolean>> containsCharInside(String selectedText, char selected, char typed) {
    boolean isEscaped = false;
    List<Pair<Integer, Boolean>> result = null;
    for (int i = 0; i < selectedText.length(); i++) {
      char c = selectedText.charAt(i);
      if (isEscaped) {
        if (c == selected || c == typed) {
          if (result == null) result = new ArrayList<>();
          result.add(Pair.create(i, true));
        }
        isEscaped = false;
      }
      else if (c == '\\') {
        isEscaped = true;
      }
      else if (c == selected || c == typed) {
        if (result == null) result = new ArrayList<>();
        result.add(Pair.create(i, false));
      }
    }
    return result != null ? result : Collections.emptyList();
  }
private static @NotNull List<Pair<Integer, Boolean>> containsCharInside(String selectedText, char selected, char typed)