private void applyLinkResultsOrReschedule()

in core/src/com/jediterm/terminal/model/hyperlinks/TextProcessing.java [85:113]


  private void applyLinkResultsOrReschedule(@NotNull LinesStorage linesStorage,
                                            @NotNull LineInfoImpl lineInfo,
                                            @NotNull List<LinkResultItem> resultItems,
                                            int attemptNumber) {
    if (resultItems.isEmpty()) return;
    myTerminalTextBuffer.lock();
    try {
      String lineStr = lineInfo.getLine();
      if (lineStr == null) return;
      int terminalWidth = myTerminalTextBuffer.getWidth();
      if (lineInfo.myTerminalWidth == terminalWidth) {
        applyLinkResults(resultItems, lineInfo, lineStr);
      }
      else if (attemptNumber < MAX_RESCHEDULING_ATTEMPTS) {
        // All `TerminalLine` instances are re-created by `ChangeWidthOperation`.
        // Therefore, `TerminalLine` instances referenced by the `lineInfo` are not in the text buffer,
        // and we need to find new lines and reschedule hyperlinks highlighting.
        List<List<TerminalLine>> matchedWrappedLines = new TerminalLineFinder(myTerminalTextBuffer, lineStr)
          .findMatchedLines(200 /* a line might be pushed to the history buffer */);
        for (List<TerminalLine> wrappedLine : matchedWrappedLines) {
          LineInfoImpl newLineInfo = new LineInfoImpl(wrappedLine, terminalWidth);
          doProcessHyperlinks(linesStorage, newLineInfo, attemptNumber + 1);
        }
      }
    }
    finally {
      myTerminalTextBuffer.unlock();
    }
  }