Expose a unique key: usize
in ExcerptBoundary
This commit is contained in:
parent
eda569d6b2
commit
5fdafbe8c9
1 changed files with 12 additions and 1 deletions
|
@ -31,6 +31,7 @@ use text::{
|
||||||
Edit, Point, PointUtf16, TextSummary,
|
Edit, Point, PointUtf16, TextSummary,
|
||||||
};
|
};
|
||||||
use theme::SyntaxTheme;
|
use theme::SyntaxTheme;
|
||||||
|
use util::post_inc;
|
||||||
|
|
||||||
const NEWLINES: &'static [u8] = &[b'\n'; u8::MAX as usize];
|
const NEWLINES: &'static [u8] = &[b'\n'; u8::MAX as usize];
|
||||||
|
|
||||||
|
@ -40,6 +41,7 @@ pub struct MultiBuffer {
|
||||||
snapshot: RefCell<MultiBufferSnapshot>,
|
snapshot: RefCell<MultiBufferSnapshot>,
|
||||||
buffers: RefCell<HashMap<usize, BufferState>>,
|
buffers: RefCell<HashMap<usize, BufferState>>,
|
||||||
used_excerpt_ids: SumTree<ExcerptId>,
|
used_excerpt_ids: SumTree<ExcerptId>,
|
||||||
|
next_excerpt_key: usize,
|
||||||
subscriptions: Topic,
|
subscriptions: Topic,
|
||||||
singleton: bool,
|
singleton: bool,
|
||||||
replica_id: ReplicaId,
|
replica_id: ReplicaId,
|
||||||
|
@ -102,6 +104,7 @@ pub struct MultiBufferSnapshot {
|
||||||
|
|
||||||
pub struct ExcerptBoundary {
|
pub struct ExcerptBoundary {
|
||||||
pub id: ExcerptId,
|
pub id: ExcerptId,
|
||||||
|
pub key: usize,
|
||||||
pub row: u32,
|
pub row: u32,
|
||||||
pub buffer: BufferSnapshot,
|
pub buffer: BufferSnapshot,
|
||||||
pub range: ExcerptRange<text::Anchor>,
|
pub range: ExcerptRange<text::Anchor>,
|
||||||
|
@ -111,6 +114,7 @@ pub struct ExcerptBoundary {
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
struct Excerpt {
|
struct Excerpt {
|
||||||
id: ExcerptId,
|
id: ExcerptId,
|
||||||
|
key: usize,
|
||||||
buffer_id: usize,
|
buffer_id: usize,
|
||||||
buffer: BufferSnapshot,
|
buffer: BufferSnapshot,
|
||||||
range: ExcerptRange<text::Anchor>,
|
range: ExcerptRange<text::Anchor>,
|
||||||
|
@ -167,6 +171,7 @@ impl MultiBuffer {
|
||||||
snapshot: Default::default(),
|
snapshot: Default::default(),
|
||||||
buffers: Default::default(),
|
buffers: Default::default(),
|
||||||
used_excerpt_ids: Default::default(),
|
used_excerpt_ids: Default::default(),
|
||||||
|
next_excerpt_key: Default::default(),
|
||||||
subscriptions: Default::default(),
|
subscriptions: Default::default(),
|
||||||
singleton: false,
|
singleton: false,
|
||||||
replica_id,
|
replica_id,
|
||||||
|
@ -204,7 +209,8 @@ impl MultiBuffer {
|
||||||
Self {
|
Self {
|
||||||
snapshot: RefCell::new(self.snapshot.borrow().clone()),
|
snapshot: RefCell::new(self.snapshot.borrow().clone()),
|
||||||
buffers: RefCell::new(buffers),
|
buffers: RefCell::new(buffers),
|
||||||
used_excerpt_ids: Default::default(),
|
used_excerpt_ids: self.used_excerpt_ids.clone(),
|
||||||
|
next_excerpt_key: self.next_excerpt_key,
|
||||||
subscriptions: Default::default(),
|
subscriptions: Default::default(),
|
||||||
singleton: self.singleton,
|
singleton: self.singleton,
|
||||||
replica_id: self.replica_id,
|
replica_id: self.replica_id,
|
||||||
|
@ -829,6 +835,7 @@ impl MultiBuffer {
|
||||||
};
|
};
|
||||||
let excerpt = Excerpt::new(
|
let excerpt = Excerpt::new(
|
||||||
id.clone(),
|
id.clone(),
|
||||||
|
post_inc(&mut self.next_excerpt_key),
|
||||||
buffer_id,
|
buffer_id,
|
||||||
buffer_snapshot.clone(),
|
buffer_snapshot.clone(),
|
||||||
range,
|
range,
|
||||||
|
@ -1288,6 +1295,7 @@ impl MultiBuffer {
|
||||||
|
|
||||||
new_excerpt = Excerpt::new(
|
new_excerpt = Excerpt::new(
|
||||||
id.clone(),
|
id.clone(),
|
||||||
|
old_excerpt.key,
|
||||||
buffer_id,
|
buffer_id,
|
||||||
buffer.snapshot(),
|
buffer.snapshot(),
|
||||||
old_excerpt.range.clone(),
|
old_excerpt.range.clone(),
|
||||||
|
@ -2247,6 +2255,7 @@ impl MultiBufferSnapshot {
|
||||||
let starts_new_buffer = Some(excerpt.buffer_id) != prev_buffer_id;
|
let starts_new_buffer = Some(excerpt.buffer_id) != prev_buffer_id;
|
||||||
let boundary = ExcerptBoundary {
|
let boundary = ExcerptBoundary {
|
||||||
id: excerpt.id.clone(),
|
id: excerpt.id.clone(),
|
||||||
|
key: excerpt.key,
|
||||||
row: cursor.start().1.row,
|
row: cursor.start().1.row,
|
||||||
buffer: excerpt.buffer.clone(),
|
buffer: excerpt.buffer.clone(),
|
||||||
range: excerpt.range.clone(),
|
range: excerpt.range.clone(),
|
||||||
|
@ -2675,6 +2684,7 @@ impl History {
|
||||||
impl Excerpt {
|
impl Excerpt {
|
||||||
fn new(
|
fn new(
|
||||||
id: ExcerptId,
|
id: ExcerptId,
|
||||||
|
key: usize,
|
||||||
buffer_id: usize,
|
buffer_id: usize,
|
||||||
buffer: BufferSnapshot,
|
buffer: BufferSnapshot,
|
||||||
range: ExcerptRange<text::Anchor>,
|
range: ExcerptRange<text::Anchor>,
|
||||||
|
@ -2682,6 +2692,7 @@ impl Excerpt {
|
||||||
) -> Self {
|
) -> Self {
|
||||||
Excerpt {
|
Excerpt {
|
||||||
id,
|
id,
|
||||||
|
key,
|
||||||
max_buffer_row: range.context.end.to_point(&buffer).row,
|
max_buffer_row: range.context.end.to_point(&buffer).row,
|
||||||
text_summary: buffer
|
text_summary: buffer
|
||||||
.text_summary_for_range::<TextSummary, _>(range.context.to_offset(&buffer)),
|
.text_summary_for_range::<TextSummary, _>(range.context.to_offset(&buffer)),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue