Ragex.Editor.Undo
(Ragex v0.10.1)
View Source
Multi-level undo/redo stack for refactoring operations.
Provides persistent history of refactoring operations with the ability
to undo and redo changes. History is stored per-project in:
~/.ragex/undo/<project_hash>/
Each undo entry contains:
- Operation metadata (type, timestamp, parameters)
- File states before the operation
- Operation result (success/failure)
Summary
Functions
Clears the undo history for a project.
Lists the undo history for a project.
Pushes a new operation onto the undo stack.
Redoes the most recently undone operation.
Undoes the most recent operation.
Types
@type operation_type() ::
:rename_function
| :rename_module
| :extract_function
| :inline_function
| :convert_visibility
| :rename_parameter
| :modify_attributes
| :change_signature
| :move_function
| :extract_module
@type undo_entry() :: %{ id: String.t(), operation: operation_type(), timestamp: DateTime.t(), params: map(), files_affected: [String.t()], file_states: %{required(String.t()) => String.t()}, result: :success | :failure, description: String.t() }
@type undo_stack() :: [undo_entry()]
Functions
@spec clear_undo_stack( String.t(), keyword() ) :: {:ok, non_neg_integer()} | {:error, term()}
Clears the undo history for a project.
Parameters
project_path: Project root pathopts: Options:keep_last- Number of entries to keep (default: 0)
Returns
{:ok, count}number of entries cleared
@spec list_undo_stack( String.t(), keyword() ) :: {:ok, [undo_entry()]} | {:error, term()}
Lists the undo history for a project.
Parameters
project_path: Project root pathopts: Options:limit- Maximum entries to return (default: 50):include_undone- Include undone entries (default: false)
Returns
{:ok, entries}list of undo entries
@spec push_undo( String.t(), operation_type(), map(), [String.t()], :success | :failure ) :: {:ok, String.t()} | {:error, term()}
Pushes a new operation onto the undo stack.
Parameters
project_path: Project root pathoperation: Operation type atomparams: Operation parametersfiles_affected: List of file pathsresult: Operation result
Returns
{:ok, entry_id}on success{:error, reason}on failure
Redoes the most recently undone operation.
Parameters
project_path: Project root path
Returns
{:ok, result}with redo details on success{:error, reason}on failure
Undoes the most recent operation.
Parameters
project_path: Project root path
Returns
{:ok, result}with undo details on success{:error, reason}on failure