public boolean undoLine(@NotNull Editor editor, DataContext context) { if (pointer == 0 && getMaxUndos() == 0) { return redo(editor, context); } if (pointer > 0) { int lastLine = -1; pointer--; UndoCommand cmd = undos.get(pointer); if (logger.isDebugEnabled()) logger.debug("undo command " + pointer); while (cmd.isOneLine() && (lastLine == -1 || cmd.getLine() == lastLine)) { lastLine = cmd.getLine(); inUndo = true; cmd.undo(editor, context); inUndo = false; if (pointer > 0) { pointer--; cmd = undos.get(pointer); } else { break; } } return true; } return false; }
public boolean redo(@NotNull Editor editor, DataContext context) { if (pointer < undos.size()) { UndoCommand cmd = undos.get(pointer); if (logger.isDebugEnabled()) logger.debug("redo command " + pointer); pointer++; inUndo = true; cmd.redo(editor, context); inUndo = false; return true; } return false; }
public boolean undo(@NotNull Editor editor, @NotNull DataContext context) { if (pointer == 0 && getMaxUndos() == 0) { return redo(editor, context); } if (pointer > 0) { pointer--; UndoCommand cmd = undos.get(pointer); if (logger.isDebugEnabled()) logger.debug("undo command " + pointer); inUndo = true; cmd.undo(editor, context); inUndo = false; if (pointer == 0 && restorable) { Project p = PlatformDataKeys.PROJECT.getData(context); DocumentManager.getInstance().reloadDocument(editor.getDocument(), p); } return true; } return false; }