pub struct FileHunks {
pub path: PathBuf,
pub text: String,
pub ranges: Vec<(u32, u32)>,
pub changed: DiffSignMap,
pub removed: Vec<(u32, Vec<String>)>,
}Expand description
One changed file, read and diffed: the working-tree text plus the post-image ranges its hunks occupy.
The two halves of building a batch are split around this type on
purpose. Producing it is filesystem + CPU work
(read_and_diff, spawn_blocking-only); consuming it spawns
document actors and touches the view (attach_batch, async side).
Fusing them — the PD.1 shape, where one function read, diffed and
spawned — would have put every read_to_string and every diff on
the actor thread the moment a trigger existed to call it.
Fields§
§path: PathBuf§text: StringThe working-tree text, as read during the scan.
ranges: Vec<(u32, u32)>Post-image excerpt ranges, one per hunk, context already applied.
changed: DiffSignMapPD.7a: which post-image lines the diff touched, in source line coordinates, sorted.
Only Add and Change appear. A removed line has no post-image
row to paint — showing it needs a virtual row, which is PD.7b.
Recording nothing for it here is why this view currently reads as
“some lines are highlighted” rather than “these lines went away”.
removed: Vec<(u32, Vec<String>)>PD.7b: lines the diff removed, keyed by the post-image line they sat above and carrying the removed text.
These have no row in the working-tree file — that is what “removed”
means — so they cannot be painted like changed. They render as
virtual rows anchored above the post-image line, which is also why
they are unselectable and untypeable: a line that is not in the file
is not a line you can edit, and the ghost row makes that visible
rather than surprising.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FileHunks
impl RefUnwindSafe for FileHunks
impl Send for FileHunks
impl Sync for FileHunks
impl Unpin for FileHunks
impl UnsafeUnpin for FileHunks
impl UnwindSafe for FileHunks
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
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