public void redo() {
    if (patchIndex >= undoPatches.size()) {
      return;
    }
    UndoPatch p = undoPatches.get(patchIndex++);
    // Perform patch
    int prow;
    for (prow = 0; prow < p.oldText.length; prow++) {
      if (prow >= p.patchText.length) {
        for (int da = p.oldText.length - prow; da > 0; da--) {
          code.remove(p.startRow + prow);
        }
        break;
      }
      code.set(p.startRow + prow, new Line(p.patchText[prow]));
    }
    while (prow < p.patchText.length) {
      code.add(p.startRow + prow, new Line(p.patchText[prow]));
      prow++;
    }
    p.cafter.replace();
    fireLineChange(p.startRow, p.startRow + p.oldText.length);
    repaint();
  }