Skip to main content

SectionIndex

Struct SectionIndex 

Source
pub struct SectionIndex {
    pub sections: Vec<Section>,
    pub branch: String,
    pub ahead: usize,
    pub behind: usize,
    pub bisect: Option<BisectState>,
    pub in_flight: Option<InFlightOp>,
    pub upstream: Option<String>,
}

Fields§

§sections: Vec<Section>§branch: String§ahead: usize§behind: usize§bisect: Option<BisectState>

MG.21f: the bisect in progress, if any.

Repo state rather than a section — this struct already carries branch / ahead / behind for the same reason, and the headerline is where lattice answers “what state is this repo in” (it already carries REBASE IN PROGRESS). A SectionKind would have been the wrong home: every SectionEntry variant carries diff-bearing-file invariants — a path, a stage operation, an expandable patch — and a bisect has none of them.

§in_flight: Option<InFlightOp>

MG: the multi-commit operation the repo is stopped inside — merge, rebase, cherry-pick, revert, am — or None when idle.

Repo state like bisect, and here for the same reason: the status buffer is where a user lands to resolve conflicts, and without this it showed unmerged files with nothing saying WHAT they are unmerged from or how to get out.

§upstream: Option<String>

The upstream ref this branch tracks (origin/main), when it has one, for the Unmerged into <upstream> header.

Repo state like branch / ahead / behind, and here for the same reason: it is a fact about the repository that a section header renders, not a property of any entry.

Implementations§

Source§

impl SectionIndex

Source

pub fn format_buffer(&self) -> String

Source

pub fn format_buffer_styled(&self) -> (String, Vec<Vec<StyledSpan>>)

Source

pub fn format_buffer_styled_with( &self, inline: impl Fn(&SectionEntry, SectionKind) -> Option<(String, String)>, lang_registry: Option<&Arc<LangRegistry>>, ) -> (String, Vec<Vec<StyledSpan>>, Vec<(String, usize)>, Vec<Vec<RefineSpan>>)

MG.18d: format the buffer with each entry’s diff inlined where inline supplies one.

A refresh replaces the whole buffer, so any expansion the user had open dies with it — which at hunk granularity means losing your place after every single s. Rebuilding with the expansions is what lets the entry survive: one edit, one span vector, no splice arithmetic against a buffer that is being replaced underneath it, and no collapse-then-expand flicker.

inline(entry, kind) returns (key, diff_text) for an entry that should come back expanded. The returned Vec<(key, line_count)> is the rebuilt expansion bookkeeping — counts are recomputed rather than carried, because staging a hunk makes the diff shorter. DS-fix (2026-08-12): lang_registry is what makes a refreshed expansion look like a freshly-opened one. None degrades to the flat classifier, the same designed degradation hunk_syntax::diff_spans documents — a harness without the grammar service renders the diff the way it always did.

Trait Implementations§

Source§

impl Clone for SectionIndex

Source§

fn clone(&self) -> SectionIndex

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 SectionIndex

Source§

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

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

impl Default for SectionIndex

Source§

fn default() -> SectionIndex

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

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more