Skip to main content

EditCommand

Enum EditCommand 

Source
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

Fields

§offset: usize

Character offset to insert at.

§text: String

Text to insert.

§

Delete

Delete text in specified range

Fields

§start: usize

Character offset of the deletion start.

§length: usize

Length of the deletion in characters.

§

Replace

Replace text in specified range

Fields

§start: usize

Character offset of the replacement start.

§length: usize

Length of the replaced range in characters.

§text: String

Replacement text.

§

InsertText

VSCode-like typing/paste: apply to all carets/selections (primary + secondary)

Fields

§text: String

Text to insert/replace at each selection/caret.

§

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.

Fields

§auto_indent: bool

Whether to auto-indent the new 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: CommentConfig

Comment 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

§query: String

Search query.

§replacement: String

Replacement text.

§options: SearchOptions

Search 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.

Fields

§query: String

Search query.

§replacement: String

Replacement text.

§options: SearchOptions

Search options (case sensitivity, whole-word, regex).

Trait Implementations§

Source§

impl Clone for EditCommand

Source§

fn clone(&self) -> EditCommand

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EditCommand

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for EditCommand

Source§

fn eq(&self, other: &EditCommand) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for EditCommand

Source§

impl StructuralPartialEq for EditCommand

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.