Start painting some sort of hunk info, it's wrong but it's close

Co-Authored-By: Max Brunsfeld <max@zed.dev>
This commit is contained in:
Julia 2022-09-01 17:22:12 -04:00
parent 6fa2e62fa4
commit 55ca02351c
10 changed files with 286 additions and 8 deletions

View file

@ -7,9 +7,10 @@ use collections::{BTreeMap, Bound, HashMap, HashSet};
use gpui::{AppContext, Entity, ModelContext, ModelHandle, Task};
pub use language::Completion;
use language::{
char_kind, AutoindentMode, Buffer, BufferChunks, BufferSnapshot, CharKind, Chunk,
DiagnosticEntry, Event, File, IndentSize, Language, OffsetRangeExt, Outline, OutlineItem,
Selection, ToOffset as _, ToOffsetUtf16 as _, ToPoint as _, ToPointUtf16 as _, TransactionId,
char_kind, git::DiffHunk, AutoindentMode, Buffer, BufferChunks, BufferSnapshot, CharKind,
Chunk, DiagnosticEntry, Event, File, IndentSize, Language, OffsetRangeExt, Outline,
OutlineItem, Selection, ToOffset as _, ToOffsetUtf16 as _, ToPoint as _, ToPointUtf16 as _,
TransactionId,
};
use smallvec::SmallVec;
use std::{
@ -2529,6 +2530,15 @@ impl MultiBufferSnapshot {
})
}
pub fn diff_hunks_in_range<'a>(
&'a self,
row_range: Range<u32>,
) -> impl 'a + Iterator<Item = DiffHunk<u32>> {
self.as_singleton()
.into_iter()
.flat_map(move |(_, _, buffer)| buffer.diff_hunks_in_range(row_range.clone()))
}
pub fn range_for_syntax_ancestor<T: ToOffset>(&self, range: Range<T>) -> Option<Range<usize>> {
let range = range.start.to_offset(self)..range.end.to_offset(self);