Start on text highlight support

This commit is contained in:
Nathan Sobo 2022-03-09 14:53:31 -07:00
parent 3dc100adfb
commit ac1eb19f83
15 changed files with 198 additions and 91 deletions

View file

@ -12,7 +12,7 @@ use crate::{
use anyhow::{anyhow, Result};
use clock::ReplicaId;
use futures::FutureExt as _;
use gpui::{AppContext, Entity, ModelContext, MutableAppContext, Task};
use gpui::{fonts::HighlightStyle, AppContext, Entity, ModelContext, MutableAppContext, Task};
use lazy_static::lazy_static;
use parking_lot::Mutex;
use similar::{ChangeTag, TextDiff};
@ -248,7 +248,8 @@ pub struct BufferChunks<'a> {
#[derive(Clone, Copy, Debug, Default)]
pub struct Chunk<'a> {
pub text: &'a str,
pub highlight_id: Option<HighlightId>,
pub syntax_highlight_id: Option<HighlightId>,
pub highlight_style: Option<HighlightStyle>,
pub diagnostic: Option<DiagnosticSeverity>,
}
@ -1716,7 +1717,7 @@ impl BufferSnapshot {
offset += chunk.text.len();
}
let style = chunk
.highlight_id
.syntax_highlight_id
.zip(theme)
.and_then(|(highlight, theme)| highlight.style(theme));
if let Some(style) = style {
@ -2086,7 +2087,8 @@ impl<'a> Iterator for BufferChunks<'a> {
Some(Chunk {
text: slice,
highlight_id,
syntax_highlight_id: highlight_id,
highlight_style: None,
diagnostic: self.current_diagnostic_severity(),
})
} else {