Merge branch 'main' into settings-file
This commit is contained in:
commit
b33a049958
27 changed files with 1304 additions and 448 deletions
|
@ -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};
|
||||
|
@ -246,7 +246,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>,
|
||||
}
|
||||
|
||||
|
@ -1728,7 +1729,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 {
|
||||
|
@ -2102,7 +2103,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 {
|
||||
|
|
|
@ -8,7 +8,7 @@ pub struct HighlightMap(Arc<[HighlightId]>);
|
|||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct HighlightId(pub u32);
|
||||
|
||||
const DEFAULT_HIGHLIGHT_ID: HighlightId = HighlightId(u32::MAX);
|
||||
const DEFAULT_SYNTAX_HIGHLIGHT_ID: HighlightId = HighlightId(u32::MAX);
|
||||
|
||||
impl HighlightMap {
|
||||
pub fn new(capture_names: &[String], theme: &SyntaxTheme) -> Self {
|
||||
|
@ -36,7 +36,7 @@ impl HighlightMap {
|
|||
Some((i, len))
|
||||
})
|
||||
.max_by_key(|(_, len)| *len)
|
||||
.map_or(DEFAULT_HIGHLIGHT_ID, |(i, _)| HighlightId(i as u32))
|
||||
.map_or(DEFAULT_SYNTAX_HIGHLIGHT_ID, |(i, _)| HighlightId(i as u32))
|
||||
})
|
||||
.collect(),
|
||||
)
|
||||
|
@ -46,7 +46,7 @@ impl HighlightMap {
|
|||
self.0
|
||||
.get(capture_id as usize)
|
||||
.copied()
|
||||
.unwrap_or(DEFAULT_HIGHLIGHT_ID)
|
||||
.unwrap_or(DEFAULT_SYNTAX_HIGHLIGHT_ID)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ impl Default for HighlightMap {
|
|||
|
||||
impl Default for HighlightId {
|
||||
fn default() -> Self {
|
||||
DEFAULT_HIGHLIGHT_ID
|
||||
DEFAULT_SYNTAX_HIGHLIGHT_ID
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -516,7 +516,7 @@ impl Language {
|
|||
for chunk in BufferChunks::new(text, range, Some(&tree), self.grammar.as_ref(), vec![])
|
||||
{
|
||||
let end_offset = offset + chunk.text.len();
|
||||
if let Some(highlight_id) = chunk.highlight_id {
|
||||
if let Some(highlight_id) = chunk.syntax_highlight_id {
|
||||
result.push((offset..end_offset, highlight_id));
|
||||
}
|
||||
offset = end_offset;
|
||||
|
|
|
@ -4,7 +4,6 @@ use crate::{
|
|||
};
|
||||
use anyhow::{anyhow, Result};
|
||||
use clock::ReplicaId;
|
||||
use collections::HashSet;
|
||||
use lsp::DiagnosticSeverity;
|
||||
use rpc::proto;
|
||||
use std::{ops::Range, sync::Arc};
|
||||
|
@ -100,26 +99,6 @@ pub fn serialize_undo_map_entry(
|
|||
}
|
||||
}
|
||||
|
||||
pub fn serialize_buffer_fragment(fragment: &text::Fragment) -> proto::BufferFragment {
|
||||
proto::BufferFragment {
|
||||
replica_id: fragment.insertion_timestamp.replica_id as u32,
|
||||
local_timestamp: fragment.insertion_timestamp.local,
|
||||
lamport_timestamp: fragment.insertion_timestamp.lamport,
|
||||
insertion_offset: fragment.insertion_offset as u32,
|
||||
len: fragment.len as u32,
|
||||
visible: fragment.visible,
|
||||
deletions: fragment
|
||||
.deletions
|
||||
.iter()
|
||||
.map(|clock| proto::VectorClockEntry {
|
||||
replica_id: clock.replica_id as u32,
|
||||
timestamp: clock.value,
|
||||
})
|
||||
.collect(),
|
||||
max_undos: serialize_version(&fragment.max_undos),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn serialize_selections(selections: &Arc<[Selection<Anchor>]>) -> Vec<proto::Selection> {
|
||||
selections
|
||||
.iter()
|
||||
|
@ -290,29 +269,6 @@ pub fn deserialize_undo_map_entry(
|
|||
)
|
||||
}
|
||||
|
||||
pub fn deserialize_buffer_fragment(
|
||||
message: proto::BufferFragment,
|
||||
ix: usize,
|
||||
count: usize,
|
||||
) -> Fragment {
|
||||
Fragment {
|
||||
id: locator::Locator::from_index(ix, count),
|
||||
insertion_timestamp: InsertionTimestamp {
|
||||
replica_id: message.replica_id as ReplicaId,
|
||||
local: message.local_timestamp,
|
||||
lamport: message.lamport_timestamp,
|
||||
},
|
||||
insertion_offset: message.insertion_offset as usize,
|
||||
len: message.len as usize,
|
||||
visible: message.visible,
|
||||
deletions: HashSet::from_iter(message.deletions.into_iter().map(|entry| clock::Local {
|
||||
replica_id: entry.replica_id as ReplicaId,
|
||||
value: entry.timestamp,
|
||||
})),
|
||||
max_undos: deserialize_version(message.max_undos),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn deserialize_selections(selections: Vec<proto::Selection>) -> Arc<[Selection<Anchor>]> {
|
||||
Arc::from(
|
||||
selections
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue