pub struct HighlightSource {
pub text: Arc<str>,
pub head: u32,
/* private fields */
}Expand description
File-side source text used to highlight a diff row with surrounding context.
Fields§
§text: Arc<str>Source-side text assembled from the diff.
head: u32Source line represented by the head of HighlightSource::text.
Implementations§
Source§impl HighlightSource
impl HighlightSource
Sourcepub fn new(text: impl Into<Arc<str>>, head: u32) -> Self
pub fn new(text: impl Into<Arc<str>>, head: u32) -> Self
Creates source text beginning at a source line.
Sourcepub fn line_index(&self, source_line: u32) -> Option<usize>
pub fn line_index(&self, source_line: u32) -> Option<usize>
Returns the zero-based source-text line index for a source line.
Sourcepub fn line(&self, source_line: u32) -> Option<&str>
pub fn line(&self, source_line: u32) -> Option<&str>
Returns one source line without its trailing line terminator.
Sourcepub fn matches_hunk(&self, hunk: &Hunk, side: DiffSide) -> bool
pub fn matches_hunk(&self, hunk: &Hunk, side: DiffSide) -> bool
Returns whether this source reproduces every row hunk shows on side.
Highlighted rows are rendered from the source text, not the diff, so a source that has drifted from the patch would display lines the patch never contained. Worktree files drift whenever they are edited after the diff was produced.
Trait Implementations§
Source§impl Clone for HighlightSource
impl Clone for HighlightSource
Source§impl Debug for HighlightSource
impl Debug for HighlightSource
impl Eq for HighlightSource
Source§impl PartialEq for HighlightSource
impl PartialEq for HighlightSource
impl StructuralPartialEq for HighlightSource
Auto Trait Implementations§
impl Freeze for HighlightSource
impl RefUnwindSafe for HighlightSource
impl Send for HighlightSource
impl Sync for HighlightSource
impl Unpin for HighlightSource
impl UnsafeUnpin for HighlightSource
impl UnwindSafe for HighlightSource
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