pub enum EditCommand {
Show 28 variants
Insert {
offset: usize,
text: String,
},
Delete {
start: usize,
length: usize,
},
Replace {
start: usize,
length: usize,
text: String,
},
InsertText {
text: String,
},
InsertTab,
InsertNewline {
auto_indent: bool,
},
Indent,
Outdent,
DuplicateLines,
DeleteLines,
MoveLinesUp,
MoveLinesDown,
JoinLines,
SplitLine,
ToggleComment {
config: CommentConfig,
},
ApplyTextEdits {
edits: Vec<TextEditSpec>,
},
DeleteToPrevTabStop,
DeleteGraphemeBack,
DeleteGraphemeForward,
DeleteWordBack,
DeleteWordForward,
Backspace,
DeleteForward,
Undo,
Redo,
EndUndoGroup,
ReplaceCurrent {
query: String,
replacement: String,
options: SearchOptions,
},
ReplaceAll {
query: String,
replacement: String,
options: SearchOptions,
},
}Expand description
Text editing commands
Variants§
Insert
Insert text at the specified position
Delete
Delete text in specified range
Fields
Replace
Replace text in specified range
Fields
InsertText
VSCode-like typing/paste: apply to all carets/selections (primary + secondary)
InsertTab
Insert a tab at each caret (or replace each selection), using the current tab settings.
- If
TabKeyBehavior::Tab, inserts'\t'. - If
TabKeyBehavior::Spaces, inserts spaces up to the next tab stop.
InsertNewline
Insert a newline at each caret (or replace each selection).
If auto_indent is true, the inserted newline is followed by the leading whitespace
prefix of the current logical line.
Indent
Indent the selected lines (or the current line for an empty selection).
Outdent
Outdent the selected lines (or the current line for an empty selection).
DuplicateLines
Duplicate the selected line(s) (or the current line for an empty selection).
This is a line-based operation and will act on all carets/selections (primary + secondary), including rectangular selections.
DeleteLines
Delete the selected line(s) (or the current line for an empty selection).
This is a line-based operation and will act on all carets/selections (primary + secondary), including rectangular selections.
MoveLinesUp
Move the selected line(s) up by one line.
This is a line-based operation and will act on all carets/selections (primary + secondary), including rectangular selections.
MoveLinesDown
Move the selected line(s) down by one line.
This is a line-based operation and will act on all carets/selections (primary + secondary), including rectangular selections.
JoinLines
Join the current line with the next line (for each caret/selection).
If multiple carets/selections exist, joins are applied from bottom to top to keep offsets stable.
SplitLine
Split the current line at each caret (or replace each selection) by inserting a newline.
This is a convenience alias for EditCommand::InsertNewline with auto_indent: false.
ToggleComment
Toggle comments for the selected line(s) or selection ranges, using a language-provided comment configuration.
Fields
config: CommentConfigComment tokens/config for the current language (data-driven).
ApplyTextEdits
Apply a batch of text edits as a single undoable step.
- Edits are interpreted in pre-edit character offsets.
- Edits must be non-overlapping; they are applied in descending offset order internally.
Fields
edits: Vec<TextEditSpec>The edit list (character offsets, half-open).
DeleteToPrevTabStop
Smart backspace: if the caret is in leading whitespace, delete back to the previous tab stop.
Otherwise, behaves like EditCommand::Backspace.
DeleteGraphemeBack
Delete the previous Unicode grapheme cluster (UAX #29) for each caret/selection.
DeleteGraphemeForward
Delete the next Unicode grapheme cluster (UAX #29) for each caret/selection.
DeleteWordBack
Delete back to the previous Unicode word boundary (UAX #29) for each caret/selection.
DeleteWordForward
Delete forward to the next Unicode word boundary (UAX #29) for each caret/selection.
Backspace
Backspace-like deletion: delete selection(s) if any, otherwise delete 1 char before each caret.
DeleteForward
Delete key-like deletion: delete selection(s) if any, otherwise delete 1 char after each caret.
Undo
Undo last edit operation (supports grouping)
Redo
Redo last undone operation (supports grouping)
EndUndoGroup
Explicitly end the current undo group (for idle or external boundaries)
ReplaceCurrent
Replace the current occurrence of query (based on selection/caret) with replacement.
- Honors
options(case sensitivity / whole-word / regex). - Treated as a single undoable edit.
Fields
options: SearchOptionsSearch options (case sensitivity, whole-word, regex).
ReplaceAll
Replace all occurrences of query with replacement.
- Honors
options(case sensitivity / whole-word / regex). - Treated as a single undoable edit.
Trait Implementations§
Source§impl Clone for EditCommand
impl Clone for EditCommand
Source§fn clone(&self) -> EditCommand
fn clone(&self) -> EditCommand
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more