pub struct SelectionState {
pub ranges: Vec<RangeState>,
pub primary_range: usize,
}Fields§
§ranges: Vec<RangeState>§primary_range: usizeImplementations§
Source§impl SelectionState
impl SelectionState
pub fn transform(&mut self, ops: &Edit, text: &Rope)
pub fn sort(&mut self)
Sourcepub fn merge_overlapping(&mut self)
pub fn merge_overlapping(&mut self)
Merge sorted ranges sharing a grapheme into the earlier range. Ranges that merely touch stay separate. The primary range follows the range it merges into.
When to merge:
- Merge after selection motions and seeks (e.g.
h/j/k/l/f/t/x, mouse clicks/drags, etc). - Merge after
<a-o>/<a-O>, which edit the buffer without entering insert mode. - Merge before
d/c/r, but not after, so cursors that coincide after deleting stay separate. - Merge after undo and redo. Kakoune instead replaces the selection with the modified ranges, which are always merged.
- Merge before
R. Kakoune doesn’t; it replaces one range at a time, so coincident cursors replace successive graphemes. Merging keepsRa single edit, for now.
When not to merge:
- Never merge in insert mode or when entering it (
i/a/I/A/o/O), so coincident cursors each insert their own text. Kakoune does merge on insert-mode cursor movement (e.g. arrows), which Indigo doesn’t support yet. - Never merge after
;,<a-;>, or<a-:>. - Never merge after
sor<a-s>; they only sort.
Except for R, we follow Kakoune.
Sourcepub fn contains(&self, other: &Self) -> bool
pub fn contains(&self, other: &Self) -> bool
Whether every range in other lies within the range at the same index in self.
pub fn save(&self, text: &Text) -> SelectionSnapshot
Trait Implementations§
Source§impl Clone for SelectionState
impl Clone for SelectionState
Source§fn clone(&self) -> SelectionState
fn clone(&self) -> SelectionState
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for SelectionState
impl RefUnwindSafe for SelectionState
impl Send for SelectionState
impl Sync for SelectionState
impl Unpin for SelectionState
impl UnsafeUnpin for SelectionState
impl UnwindSafe for SelectionState
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more