mirror of
https://github.com/zed-industries/zed.git
synced 2026-12-03 05:51:27 +01:00
editor: Implement semantic highlighting (#46356)
Part of #7450 Big thanks to @macmv for pushing this forwards so much! Rebased version of https://github.com/zed-industries/zed/pull/39539 as working on an in-org branch simplifies a lot of things for us) Release Notes: - Added LSP semantic tokens highlighting support --------- Co-authored-by: Neil Macneale V <neil.macneale.v@gmail.com> Co-authored-by: Kirill Bulatov <kirill@zed.dev> Co-authored-by: Zed Zippy <234243425+zed-zippy[bot]@users.noreply.github.com>
This commit is contained in:
@@ -6,7 +6,9 @@ mod transaction;
|
||||
|
||||
use self::transaction::History;
|
||||
|
||||
pub use anchor::{Anchor, AnchorRangeExt};
|
||||
pub use anchor::{
|
||||
Anchor, AnchorHasDiffbaseError, AnchorRangeExt, DiffbaselessAnchor, DiffbaselessAnchorRangeExt,
|
||||
};
|
||||
|
||||
use anyhow::{Result, anyhow};
|
||||
use buffer_diff::{
|
||||
@@ -7299,6 +7301,23 @@ impl Excerpt {
|
||||
.is_ge()
|
||||
}
|
||||
|
||||
fn contains_diffbaseless(&self, anchor: &DiffbaselessAnchor) -> bool {
|
||||
(anchor.text_anchor.buffer_id == None
|
||||
|| anchor.text_anchor.buffer_id == Some(self.buffer_id))
|
||||
&& self
|
||||
.range
|
||||
.context
|
||||
.start
|
||||
.cmp(&anchor.text_anchor, &self.buffer)
|
||||
.is_le()
|
||||
&& self
|
||||
.range
|
||||
.context
|
||||
.end
|
||||
.cmp(&anchor.text_anchor, &self.buffer)
|
||||
.is_ge()
|
||||
}
|
||||
|
||||
/// The [`Excerpt`]'s start offset in its [`Buffer`]
|
||||
fn buffer_start_offset(&self) -> BufferOffset {
|
||||
BufferOffset(self.range.context.start.to_offset(&self.buffer))
|
||||
@@ -7427,6 +7446,12 @@ impl<'a> MultiBufferExcerpt<'a> {
|
||||
&& range.end <= self.excerpt.buffer_end_offset()
|
||||
}
|
||||
|
||||
/// Returns true if any part of the given range is in the buffer's excerpt
|
||||
pub fn contains_partial_buffer_range(&self, range: Range<BufferOffset>) -> bool {
|
||||
range.start <= self.excerpt.buffer_end_offset()
|
||||
&& range.end >= self.excerpt.buffer_start_offset()
|
||||
}
|
||||
|
||||
pub fn max_buffer_row(&self) -> u32 {
|
||||
self.excerpt.max_buffer_row
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user