private @NotNull String getLineTextUpToCursor(@Nullable TerminalLine line) {
      if (line == null) return "";
      return processTerminalBuffer(textBuffer -> {
        int cursorX = getTerminal().getCursorX() - 1;
        String lineStr = line.getText();
        int maxCursorX = Math.max(myMaxCursorX, cursorX);
        while (maxCursorX < lineStr.length() && !Character.isWhitespace(lineStr.charAt(maxCursorX))) {
          maxCursorX++;
        }
        myMaxCursorX = maxCursorX;
        return lineStr.substring(0, Math.min(maxCursorX, lineStr.length()));
      });
    }
private @NotNull String getLineTextUpToCursor(@Nullable TerminalLine line)