Skip to main content

FoldingManager

Struct FoldingManager 

Source
pub struct FoldingManager { /* private fields */ }
Expand description

Folding manager

Implementations§

Source§

impl FoldingManager

Source

pub fn new() -> Self

Create an empty folding manager.

Source

pub fn add_region(&mut self, region: FoldRegion)

Add fold region

Source

pub fn remove_region(&mut self, start_line: usize, end_line: usize) -> bool

Remove fold region

Source

pub fn get_region_for_line(&self, line: usize) -> Option<&FoldRegion>

Get fold region containing specified line

Source

pub fn get_region_for_line_mut( &mut self, line: usize, ) -> Option<&mut FoldRegion>

Get mutable reference

Source

pub fn collapse_line(&mut self, line: usize) -> bool

Collapse specified line

Source

pub fn expand_line(&mut self, line: usize) -> bool

Expand specified line

Source

pub fn toggle_line(&mut self, line: usize) -> bool

Toggle fold state of specified line

Source

pub fn toggle_region_starting_at_line(&mut self, start_line: usize) -> bool

Toggle fold region starting at specified line (preferring “innermost” region).

rust-analyzer / LSP folding ranges often contain nested regions. To make TUI and other frontends behave more intuitively when “cursor is on a start line”, we choose:

  • Among all regions with start_line == line, the one with smallest end_line (innermost)
Source

pub fn logical_to_visual( &self, logical_line: usize, base_visual: usize, ) -> Option<usize>

Calculate mapping from logical line to visual line

Returns the visual line number for the specified logical line number, or None if folded

Source

pub fn visual_to_logical(&self, visual_line: usize, base_visual: usize) -> usize

Calculate mapping from visual line to logical line

Source

pub fn regions(&self) -> &[FoldRegion]

Get all fold regions

Source

pub fn clear(&mut self)

Clear all fold regions

Source

pub fn replace_regions(&mut self, regions: Vec<FoldRegion>)

Replace fold regions with new list (will be sorted by start line and deduplicated).

Source

pub fn expand_all(&mut self)

Expand all folds

Source

pub fn collapse_all(&mut self)

Collapse all regions

Trait Implementations§

Source§

impl Default for FoldingManager

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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