pub enum CursorAffinity {
Forward,
Backward,
}
Expand description
Decides how the cursor should be placed around special areas of text.
Ex:
let j = // soft linewrap
1 + 2 + 3;
where let j =
has the issue that there’s two positions you might want your cursor to be:
let j = |
or |1 + 2 + 3;
These are the same offset in the text, but it feels more natural to have it move in a certain
way.
If you’re at let j =|
and you press the right-arrow key, then it uses your backwards
affinity to keep you on the line at let j = |
.
If you’re at 1| + 2 + 3;
and you press the left-arrow key, then it uses your forwards affinity
to keep you on the line at |1 + 2 + 3;
.
For other special text, like inlay hints, this can also apply.
let j<: String> = ...
where <: String>
is our inlay hint, then
let |j<: String> =
and you press the right-arrow key, then it uses your backwards affinity to
keep you on the same side of the hint, let j|<: String>
.
let j<: String> |=
and you press the right-arrow key, then it uses your forwards affinity to
keep you on the same side of the hint, let j<: String>| =
.
Variants§
Implementations§
Trait Implementations§
Source§impl Clone for CursorAffinity
impl Clone for CursorAffinity
Source§fn clone(&self) -> CursorAffinity
fn clone(&self) -> CursorAffinity
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for CursorAffinity
impl Debug for CursorAffinity
Source§impl<'de> Deserialize<'de> for CursorAffinity
impl<'de> Deserialize<'de> for CursorAffinity
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for CursorAffinity
impl PartialEq for CursorAffinity
Source§impl Serialize for CursorAffinity
impl Serialize for CursorAffinity
impl Copy for CursorAffinity
impl Eq for CursorAffinity
impl StructuralPartialEq for CursorAffinity
Auto Trait Implementations§
impl Freeze for CursorAffinity
impl RefUnwindSafe for CursorAffinity
impl Send for CursorAffinity
impl Sync for CursorAffinity
impl Unpin for CursorAffinity
impl UnwindSafe for CursorAffinity
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more