void run()

in core/src/com/jediterm/terminal/model/ChangeWidthOperation.java [50:117]


  void run() {
    LinesStorage historyLinesStorage = myTextBuffer.getHistoryLinesStorageOrBackup$core();
    for (int i = 0; i < historyLinesStorage.getSize(); i++) {
      TerminalLine line = historyLinesStorage.get(i);
      addLine(line);
    }
    int screenStartInd = myAllLines.size() - 1;
    if (myCurrentLine == null || myCurrentLineLength == myNewWidth) {
      screenStartInd++;
    }
    if (screenStartInd < 0) {
      throw new IndexOutOfBoundsException("screenStartInd < 0: " + screenStartInd);
    }
    LinesStorage screenLinesStorage = myTextBuffer.getScreenLinesStorageOrBackup$core();
    if (screenLinesStorage.getSize() > myTextBuffer.getHeight()) {
      LOG.warn("Terminal height < screen buffer line count: " + myTextBuffer.getHeight() + " < " + screenLinesStorage.getSize());
    }
    int oldScreenLineCount = Math.min(screenLinesStorage.getSize(), myTextBuffer.getHeight());
    for (int i = 0; i < oldScreenLineCount; i++) {
      List<TrackingPoint> points = findPointsAtY(i);
      for (TrackingPoint point : points) {
        int newX = (myCurrentLineLength + point.getX()) % myNewWidth;
        int newY = myAllLines.size() + (myCurrentLineLength + point.getX()) / myNewWidth;
        if (myCurrentLine != null) {
          newY--;
        }
        myTrackingPoints.put(point, new Point(newX, newY));
      }
      addLine(screenLinesStorage.get(i));
    }
    for (int i = oldScreenLineCount; i < myTextBuffer.getHeight(); i++) {
      List<TrackingPoint> points = findPointsAtY(i);
      for (TrackingPoint point : points) {
        int newX = point.getX() % myNewWidth;
        int newY = (i - oldScreenLineCount) + myAllLines.size() + point.getX() / myNewWidth;
        myTrackingPoints.put(point, new Point(newX, newY));
      }
    }
    
    int emptyBottomLineCount = getEmptyBottomLineCount();
    int bottomMostPointY = 0;
    for (Map.Entry<TrackingPoint, Point> entry : myTrackingPoints.entrySet()) {
      if (entry.getKey().getForceVisible()) {
        Point resultPoint = Objects.requireNonNull(entry.getValue());
        bottomMostPointY = Math.max(bottomMostPointY, resultPoint.y);
      }
    }

    screenStartInd = Math.max(screenStartInd, myAllLines.size() - Math.min(myAllLines.size(), myNewHeight) - emptyBottomLineCount);
    screenStartInd = Math.min(screenStartInd, myAllLines.size() - Math.min(myAllLines.size(), myNewHeight));
    screenStartInd = Math.max(screenStartInd, bottomMostPointY - myNewHeight + 1);
    historyLinesStorage.clear();
    LinesStorageKt.addAllToBottom(historyLinesStorage, myAllLines.subList(0, screenStartInd));
    screenLinesStorage.clear();
    LinesStorageKt.addAllToBottom(screenLinesStorage, myAllLines.subList(screenStartInd, Math.min(screenStartInd + myNewHeight, myAllLines.size())));
    for (Map.Entry<TrackingPoint, Point> entry : myTrackingPoints.entrySet()) {
      Point p = entry.getValue();
      if (p != null) {
        p.y -= screenStartInd;
      } else {
        TrackingPoint key = entry.getKey();
        p = new Point(key.getX(), key.getY());
        entry.setValue(p);
      }
      p.x = Math.min(myNewWidth, Math.max(0, p.x));
      p.y = Math.min(myNewHeight, Math.max(0, p.y));
    }
  }