Change language:⚓:min() to a constant
Co-authored-by: Antonio Scandurra <me@as-cii.com> Co-authored-by: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
f6805eb802
commit
ab631cf6c3
10 changed files with 33 additions and 62 deletions
|
@ -278,8 +278,7 @@ impl ProjectDiagnosticsEditor {
|
|||
prev_excerpt_id = excerpt_id.clone();
|
||||
first_excerpt_id.get_or_insert_with(|| prev_excerpt_id.clone());
|
||||
group_state.excerpts.push(excerpt_id.clone());
|
||||
let header_position =
|
||||
(excerpt_id.clone(), language::Anchor::build_min());
|
||||
let header_position = (excerpt_id.clone(), language::Anchor::MIN);
|
||||
|
||||
if is_first_excerpt_for_group {
|
||||
is_first_excerpt_for_group = false;
|
||||
|
|
|
@ -491,7 +491,7 @@ mod tests {
|
|||
use super::*;
|
||||
use crate::{
|
||||
movement,
|
||||
test::{marked_text, marked_text_ranges},
|
||||
test::{marked_text_ranges},
|
||||
};
|
||||
use gpui::{color::Color, elements::*, test::observe, MutableAppContext};
|
||||
use language::{Buffer, Language, LanguageConfig, RandomCharIter, SelectionGoal};
|
||||
|
@ -499,7 +499,6 @@ mod tests {
|
|||
use smol::stream::StreamExt;
|
||||
use std::{env, sync::Arc};
|
||||
use theme::SyntaxTheme;
|
||||
use unindent::Unindent;
|
||||
use util::test::sample_text;
|
||||
use Bias::*;
|
||||
|
||||
|
|
|
@ -4,8 +4,6 @@ pub mod items;
|
|||
pub mod movement;
|
||||
mod multi_buffer;
|
||||
|
||||
pub mod repro;
|
||||
|
||||
#[cfg(test)]
|
||||
mod test;
|
||||
|
||||
|
@ -4422,13 +4420,7 @@ impl Editor {
|
|||
.into_iter()
|
||||
.flat_map(|(_, ranges)| ranges),
|
||||
)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let snapshot = this.buffer.read(cx).snapshot(cx);
|
||||
let point_ranges = ranges
|
||||
.iter()
|
||||
.map(|range| range.to_point(&snapshot))
|
||||
.collect::<Vec<_>>();
|
||||
.collect();
|
||||
|
||||
this.highlight_text::<Rename>(
|
||||
ranges,
|
||||
|
|
|
@ -211,11 +211,7 @@ impl MultiBuffer {
|
|||
pub fn singleton(buffer: ModelHandle<Buffer>, cx: &mut ModelContext<Self>) -> Self {
|
||||
let mut this = Self::new(buffer.read(cx).replica_id());
|
||||
this.singleton = true;
|
||||
this.push_excerpts(
|
||||
buffer,
|
||||
[text::Anchor::build_min()..text::Anchor::build_max()],
|
||||
cx,
|
||||
);
|
||||
this.push_excerpts(buffer, [text::Anchor::MIN..text::Anchor::MAX], cx);
|
||||
this.snapshot.borrow_mut().singleton = true;
|
||||
this
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ impl Anchor {
|
|||
Self {
|
||||
buffer_id: None,
|
||||
excerpt_id: ExcerptId::min(),
|
||||
text_anchor: text::Anchor::build_min(),
|
||||
text_anchor: text::Anchor::MIN,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ impl Anchor {
|
|||
Self {
|
||||
buffer_id: None,
|
||||
excerpt_id: ExcerptId::max(),
|
||||
text_anchor: text::Anchor::build_max(),
|
||||
text_anchor: text::Anchor::MAX,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
fn test(complicated: i32, test: i32) {
|
||||
complicated;
|
||||
test;
|
||||
// 1
|
||||
// 2
|
||||
// 3
|
||||
complicated;
|
||||
test;
|
||||
}
|
|
@ -187,10 +187,10 @@ impl DiagnosticEntry<Anchor> {
|
|||
impl Default for Summary {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
start: Anchor::build_min(),
|
||||
end: Anchor::build_max(),
|
||||
min_start: Anchor::build_max(),
|
||||
max_end: Anchor::build_min(),
|
||||
start: Anchor::MIN,
|
||||
end: Anchor::MAX,
|
||||
min_start: Anchor::MAX,
|
||||
max_end: Anchor::MIN,
|
||||
count: 0,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -789,7 +789,7 @@ fn test_random_collaboration(cx: &mut MutableAppContext, mut rng: StdRng) {
|
|||
for buffer in &buffers {
|
||||
let buffer = buffer.read(cx).snapshot();
|
||||
let actual_remote_selections = buffer
|
||||
.remote_selections_in_range(Anchor::build_min()..Anchor::build_max())
|
||||
.remote_selections_in_range(Anchor::MIN..Anchor::MAX)
|
||||
.map(|(replica_id, selections)| (replica_id, selections.collect::<Vec<_>>()))
|
||||
.collect::<Vec<_>>();
|
||||
let expected_remote_selections = active_selections
|
||||
|
|
|
@ -12,21 +12,17 @@ pub struct Anchor {
|
|||
}
|
||||
|
||||
impl Anchor {
|
||||
pub fn build_min() -> Self {
|
||||
Self {
|
||||
timestamp: clock::Local::MIN,
|
||||
offset: usize::MIN,
|
||||
bias: Bias::Left,
|
||||
}
|
||||
}
|
||||
pub const MIN: Self = Self {
|
||||
timestamp: clock::Local::MIN,
|
||||
offset: usize::MIN,
|
||||
bias: Bias::Left,
|
||||
};
|
||||
|
||||
pub fn build_max() -> Self {
|
||||
Self {
|
||||
timestamp: clock::Local::MAX,
|
||||
offset: usize::MAX,
|
||||
bias: Bias::Right,
|
||||
}
|
||||
}
|
||||
pub const MAX: Self = Self {
|
||||
timestamp: clock::Local::MAX,
|
||||
offset: usize::MAX,
|
||||
bias: Bias::Right,
|
||||
};
|
||||
|
||||
pub fn cmp(&self, other: &Anchor, buffer: &BufferSnapshot) -> Result<Ordering> {
|
||||
let fragment_id_comparison = if self.timestamp == other.timestamp {
|
||||
|
|
|
@ -1318,8 +1318,8 @@ impl Buffer {
|
|||
let mut futures = Vec::new();
|
||||
for anchor in anchors {
|
||||
if !self.version.observed(anchor.timestamp)
|
||||
&& *anchor != Anchor::build_max()
|
||||
&& *anchor != Anchor::build_min()
|
||||
&& *anchor != Anchor::MAX
|
||||
&& *anchor != Anchor::MIN
|
||||
{
|
||||
let (tx, rx) = oneshot::channel();
|
||||
self.edit_id_resolvers
|
||||
|
@ -1638,9 +1638,9 @@ impl BufferSnapshot {
|
|||
let mut position = D::default();
|
||||
|
||||
anchors.map(move |anchor| {
|
||||
if *anchor == Anchor::build_min() {
|
||||
if *anchor == Anchor::MIN {
|
||||
return D::default();
|
||||
} else if *anchor == Anchor::build_max() {
|
||||
} else if *anchor == Anchor::MAX {
|
||||
return D::from_text_summary(&self.visible_text.summary());
|
||||
}
|
||||
|
||||
|
@ -1680,9 +1680,9 @@ impl BufferSnapshot {
|
|||
where
|
||||
D: TextDimension,
|
||||
{
|
||||
if *anchor == Anchor::build_min() {
|
||||
if *anchor == Anchor::MIN {
|
||||
D::default()
|
||||
} else if *anchor == Anchor::build_max() {
|
||||
} else if *anchor == Anchor::MAX {
|
||||
D::from_text_summary(&self.visible_text.summary())
|
||||
} else {
|
||||
let anchor_key = InsertionFragmentKey {
|
||||
|
@ -1718,9 +1718,9 @@ impl BufferSnapshot {
|
|||
}
|
||||
|
||||
fn fragment_id_for_anchor(&self, anchor: &Anchor) -> &Locator {
|
||||
if *anchor == Anchor::build_min() {
|
||||
if *anchor == Anchor::MIN {
|
||||
&locator::MIN
|
||||
} else if *anchor == Anchor::build_max() {
|
||||
} else if *anchor == Anchor::MAX {
|
||||
&locator::MAX
|
||||
} else {
|
||||
let anchor_key = InsertionFragmentKey {
|
||||
|
@ -1758,9 +1758,9 @@ impl BufferSnapshot {
|
|||
pub fn anchor_at<T: ToOffset>(&self, position: T, bias: Bias) -> Anchor {
|
||||
let offset = position.to_offset(self);
|
||||
if bias == Bias::Left && offset == 0 {
|
||||
Anchor::build_min()
|
||||
Anchor::MIN
|
||||
} else if bias == Bias::Right && offset == self.len() {
|
||||
Anchor::build_max()
|
||||
Anchor::MAX
|
||||
} else {
|
||||
let mut fragment_cursor = self.fragments.cursor::<usize>();
|
||||
fragment_cursor.seek(&offset, bias, &None);
|
||||
|
@ -1775,9 +1775,7 @@ impl BufferSnapshot {
|
|||
}
|
||||
|
||||
pub fn can_resolve(&self, anchor: &Anchor) -> bool {
|
||||
*anchor == Anchor::build_min()
|
||||
|| *anchor == Anchor::build_max()
|
||||
|| self.version.observed(anchor.timestamp)
|
||||
*anchor == Anchor::MIN || *anchor == Anchor::MAX || self.version.observed(anchor.timestamp)
|
||||
}
|
||||
|
||||
pub fn clip_offset(&self, offset: usize, bias: Bias) -> usize {
|
||||
|
@ -1799,7 +1797,7 @@ impl BufferSnapshot {
|
|||
where
|
||||
D: TextDimension + Ord,
|
||||
{
|
||||
self.edits_since_in_range(since, Anchor::build_min()..Anchor::build_max())
|
||||
self.edits_since_in_range(since, Anchor::MIN..Anchor::MAX)
|
||||
}
|
||||
|
||||
pub fn edited_ranges_for_transaction<'a, D>(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue