Rework SuggestionMap
to take highlight style when retrieving chunks
This commit is contained in:
parent
093e0a30e9
commit
6715e5247c
9 changed files with 95 additions and 73 deletions
|
@ -382,7 +382,7 @@ impl DisplaySnapshot {
|
|||
/// Returns text chunks starting at the given display row until the end of the file
|
||||
pub fn text_chunks(&self, display_row: u32) -> impl Iterator<Item = &str> {
|
||||
self.block_snapshot
|
||||
.chunks(display_row..self.max_point().row() + 1, false, None)
|
||||
.chunks(display_row..self.max_point().row() + 1, false, None, None)
|
||||
.map(|h| h.text)
|
||||
}
|
||||
|
||||
|
@ -390,7 +390,7 @@ impl DisplaySnapshot {
|
|||
pub fn reverse_text_chunks(&self, display_row: u32) -> impl Iterator<Item = &str> {
|
||||
(0..=display_row).into_iter().rev().flat_map(|row| {
|
||||
self.block_snapshot
|
||||
.chunks(row..row + 1, false, None)
|
||||
.chunks(row..row + 1, false, None, None)
|
||||
.map(|h| h.text)
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter()
|
||||
|
@ -398,9 +398,18 @@ impl DisplaySnapshot {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn chunks(&self, display_rows: Range<u32>, language_aware: bool) -> DisplayChunks<'_> {
|
||||
self.block_snapshot
|
||||
.chunks(display_rows, language_aware, Some(&self.text_highlights))
|
||||
pub fn chunks(
|
||||
&self,
|
||||
display_rows: Range<u32>,
|
||||
language_aware: bool,
|
||||
suggestion_highlight: Option<HighlightStyle>,
|
||||
) -> DisplayChunks<'_> {
|
||||
self.block_snapshot.chunks(
|
||||
display_rows,
|
||||
language_aware,
|
||||
Some(&self.text_highlights),
|
||||
suggestion_highlight,
|
||||
)
|
||||
}
|
||||
|
||||
pub fn chars_at(
|
||||
|
@ -1691,7 +1700,7 @@ pub mod tests {
|
|||
) -> Vec<(String, Option<Color>, Option<Color>)> {
|
||||
let snapshot = map.update(cx, |map, cx| map.snapshot(cx));
|
||||
let mut chunks: Vec<(String, Option<Color>, Option<Color>)> = Vec::new();
|
||||
for chunk in snapshot.chunks(rows, true) {
|
||||
for chunk in snapshot.chunks(rows, true, None) {
|
||||
let syntax_color = chunk
|
||||
.syntax_highlight_id
|
||||
.and_then(|id| id.style(theme)?.color);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue