Skip to main content

SelectionEdit

Enum SelectionEdit 

Source
pub enum SelectionEdit {
Show 59 variants InsertText(String), DeleteBack, DeleteForward, InsertNewlineAbove, InsertNewlineBelow, InsertNewlineSmart, ToggleBulletAtLineStart, ToggleBulletWithContinuationIndent { unit: IndentUnit, }, DeleteWordBackward, DeleteWordForward, DeleteToLineStart, DeleteToLineEnd, DeleteToBracket, DuplicateLine, DuplicateSelection, MoveLineUp, MoveLineDown, JoinLines, JoinSelectedLines, SortLines(SortKind), ReverseLines, UniqueLines, ShuffleLines(u64), TrimTrailingWhitespace, TrimTrailingWhitespaceAll, TrimWhitespaceAll, WrapAtColumn(u32), ReflowParagraph(u32), TransposeChars, TransposeWords, ChangeCase(CaseKind), Indent { unit: IndentUnit, }, Outdent { unit: IndentUnit, }, SpacesToTabs { tab_width: u32, }, TabsToSpaces { tab_width: u32, }, ConvertLineEndings(LineEnding), ConvertLineEndingsAll(LineEnding), TabsToSpacesAll { tab_width: u32, }, SurroundSelection { open: String, close: String, }, MarkdownToggleEmphasis(EmphasisKind), MarkdownSetHeading(u8), MarkdownCycleHeading(i32), MarkdownPromoteSection, MarkdownDemoteSection, MarkdownMoveSectionUp, MarkdownMoveSectionDown, MarkdownToggleBullet, MarkdownToggleNumbered, MarkdownToggleCheckbox, MarkdownToggleTask, MarkdownCycleListMarker, MarkdownRenumberList, MarkdownWrapInBlockquote, MarkdownInsertCodeFence, MarkdownInsertLink, MarkdownInsertImageRef, MarkdownStripFormatting, InsertPair { open: String, close: String, }, DeletePair { open: char, close: char, },
}
Expand description

A selection-aware edit requested by an editor command.

New variants land here as commands graduate from “named in spec” to “implemented”. Each variant maps to exactly one undo group.

Variants§

§

InsertText(String)

Insert or replace each active selection with the supplied text.

§

DeleteBack

Delete the selected text, or one character before each caret.

§

DeleteForward

Delete the selected text, or one character after each caret.

§

InsertNewlineAbove

Insert a newline on a fresh line above each selection’s line, with the caret landing on the new line.

§

InsertNewlineBelow

Insert a newline on a fresh line below each selection’s line, caret at the new line.

§

InsertNewlineSmart

Insert a newline that inherits the leading indentation of the caret’s current line.

§

ToggleBulletAtLineStart

Toggle a - bullet marker right after each selection line’s leading whitespace. Adding the marker shifts the caret’s byte column by +2 so the cursor stays on the same content character (visually unchanged). Removing it shifts by -2 (clamped to the leading-whitespace column). Plain-text variant of SelectionEdit::MarkdownToggleBullet — it doesn’t depend on markdown parse state and is meant for the Ctrl+R quick-toggle shortcut.

§

ToggleBulletWithContinuationIndent

Like SelectionEdit::ToggleBulletAtLineStart, but for a multi-line selection the add path also prepends one indent unit to every covered line after the first (turning the selection into a bulleted list whose continuation lines are indented under the first item); the strip path removes both the bullet and that indent. A single-line selection behaves identically to the plain toggle. Bound to Ctrl+Shift+R.

Fields

§unit: IndentUnit

Indent unit (tab or N spaces) prepended to continuation lines, read live from the dispatch context (mirrors editor.indent).

§

DeleteWordBackward

Delete text from the caret backward to the previous word boundary.

§

DeleteWordForward

Delete text from the caret forward to the next word boundary.

§

DeleteToLineStart

Delete from the caret back to the start of the line (or first non-whitespace if already at line start).

§

DeleteToLineEnd

Delete from the caret forward to the end of the line.

§

DeleteToBracket

Delete from the caret to the matching bracket, if any.

§

DuplicateLine

Duplicate the entire line(s) covered by each selection.

§

DuplicateSelection

Duplicate the bytes spanned by each selection (caret selections duplicate nothing).

§

MoveLineUp

Move each selected line up one position.

§

MoveLineDown

Move each selected line down one position.

§

JoinLines

Join the line below each selection’s line into the current line.

§

JoinSelectedLines

Collapse every line break within the lines covered by each selection into a single space, joining the whole selected block into one line (VS Code “Join Lines”). Distinct from SelectionEdit::JoinLines, which only folds the single line below each caret (Vim J).

§

SortLines(SortKind)

Sort the lines covered by selections.

§

ReverseLines

Reverse the order of lines covered by selections.

§

UniqueLines

Drop duplicate lines covered by selections (case-sensitive, stable).

§

ShuffleLines(u64)

Pseudo-randomly reorder the lines covered by selections, seeded for determinism (the seed is hashed into the LCG).

§

TrimTrailingWhitespace

Trim trailing whitespace from every line covered by selections.

§

TrimTrailingWhitespaceAll

Phase B14: trim trailing whitespace on every line in the buffer regardless of selection. Used by the explicit editor.trim_trailing_whitespace command and the on-save hook.

§

TrimWhitespaceAll

Strip leading and trailing whitespace from every line in the buffer (one undo group). Used by the explicit editor.trim_whitespace command. Per-line leading strip removes indentation by design — the literal “trim each line” reading, distinct from SelectionEdit::TrimTrailingWhitespaceAll.

§

WrapAtColumn(u32)

Hard-wrap each paragraph covered by selections at column columns.

§

ReflowParagraph(u32)

Reflow each paragraph at column columns, preserving leading whitespace.

§

TransposeChars

Transpose the two characters straddling each caret.

§

TransposeWords

Transpose the two words straddling each caret.

§

ChangeCase(CaseKind)

Change case of the bytes inside each selection (or the word at each caret).

§

Indent

Indent each selected line by one indent unit.

Fields

§unit: IndentUnit

Indent unit (tab or N spaces).

§

Outdent

Outdent each selected line by one indent unit.

Fields

§unit: IndentUnit

Indent unit (tab or N spaces).

§

SpacesToTabs

Replace runs of tab_width spaces with tabs.

Fields

§tab_width: u32

Number of contiguous spaces that map to one tab.

§

TabsToSpaces

Replace tabs with tab_width spaces.

Fields

§tab_width: u32

Number of spaces emitted per tab.

§

ConvertLineEndings(LineEnding)

Convert line endings of every covered line.

§

ConvertLineEndingsAll(LineEnding)

Phase C2 — convert line endings on every line in the buffer regardless of selection. Used by the status-bar click handler and the C3 mixed-LE normalize chip.

§

TabsToSpacesAll

Phase C3 — replace every tab in the buffer with tab_width spaces, regardless of selection. Used by the mixed-indent normalize chip.

Fields

§tab_width: u32

Number of spaces emitted per tab.

§

SurroundSelection

Wrap each non-empty selection in open … close.

Fields

§open: String

Inserted at the start of the selection.

§close: String

Inserted at the end of the selection.

§

MarkdownToggleEmphasis(EmphasisKind)

Toggle markdown emphasis around each selection.

§

MarkdownSetHeading(u8)

Set the heading level of each covered line. level == 0 strips the heading; 1..=6 rewrites the prefix.

§

MarkdownCycleHeading(i32)

Cycle the heading level on each covered line (+1/-1).

§

MarkdownPromoteSection

Promote (decrease level) the section enclosing each caret.

§

MarkdownDemoteSection

Demote (increase level) the section enclosing each caret.

§

MarkdownMoveSectionUp

Move the section enclosing each caret upward past the previous sibling section.

§

MarkdownMoveSectionDown

Move the section enclosing each caret downward past the next sibling section.

§

MarkdownToggleBullet

Toggle a - bullet prefix on each covered line. Shares the content-relative planner with SelectionEdit::ToggleBulletAtLineStart (plan_toggle_bullet_at_line_start), so the caret stays on the same content character across add/remove and an ordered→bullet conversion.

§

MarkdownToggleNumbered

Toggle a 1. numbered prefix on each covered line.

§

MarkdownToggleCheckbox

Toggle a [ ]/[x] checkbox prefix on each covered line.

§

MarkdownToggleTask

Toggle a - [ ] task-bullet prefix on each covered line: plain or bulleted lines gain the task marker; existing task lines drop it. Bound to Ctrl+E.

§

MarkdownCycleListMarker

Cycle the list marker between -, *, +.

§

MarkdownRenumberList

Phase B11: renumber the ordered list containing the caret.

§

MarkdownWrapInBlockquote

Prefix > on each covered line.

§

MarkdownInsertCodeFence

Wrap selections in fenced code blocks (or insert an empty fence).

Wrap each non-empty selection as [text](url) with placeholder url.

§

MarkdownInsertImageRef

Insert ![alt](path) at each caret.

§

MarkdownStripFormatting

Strip markdown formatting from every covered line: heading hashes, list/checkbox markers, blockquote prefixes, emphasis / code / strikethrough delimiters, and link syntax (keeping the link text). Conservative on intraword _ / lone * so code identifiers and arithmetic survive.

§

InsertPair

Phase-16.5 auto-pair insert: at each caret, insert open immediately followed by close, leaving the caret between them. Lands as one undo group. Selections that already cover a non-empty range fall back to surrounding the range with open … close (so highlight + ( keeps the surround behavior of Self::SurroundSelection).

Fields

§open: String

Leading character (e.g. ().

§close: String

Trailing character (e.g. )).

§

DeletePair

Phase-16.5 backspace-aware delete-pair: at each caret, if the preceding byte is open and the following byte is close, delete both as one undo group. Otherwise the planner returns Ok(None) so the caller can fall through to a normal Self::DeleteBack.

Fields

§open: char

Open delimiter to the left of the caret.

§close: char

Close delimiter to the right of the caret.

Trait Implementations§

Source§

impl Clone for SelectionEdit

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for SelectionEdit

Source§

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

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

impl Eq for SelectionEdit

Source§

impl PartialEq for SelectionEdit

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for SelectionEdit

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.