Skip to main content

EditCommand

Enum EditCommand 

Source
pub enum EditCommand {
    Insert {
        offset: usize,
        text: String,
    },
    Delete {
        start: usize,
        length: usize,
    },
    Replace {
        start: usize,
        length: usize,
        text: String,
    },
    InsertText {
        text: String,
    },
    InsertTab,
    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.
§

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.