Follow-up fixes for recent multi buffer optimizations (#26345)
I realized that the optimization broke multi buffer syncing after buffer reparses. Release Notes: - N/A
This commit is contained in:
parent
8a7a78fafb
commit
fff37ab823
1 changed files with 9 additions and 3 deletions
|
@ -1527,6 +1527,7 @@ impl Buffer {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn did_finish_parsing(&mut self, syntax_snapshot: SyntaxSnapshot, cx: &mut Context<Self>) {
|
fn did_finish_parsing(&mut self, syntax_snapshot: SyntaxSnapshot, cx: &mut Context<Self>) {
|
||||||
|
self.was_changed();
|
||||||
self.non_text_state_update_count += 1;
|
self.non_text_state_update_count += 1;
|
||||||
self.syntax_map.lock().did_parse(syntax_snapshot);
|
self.syntax_map.lock().did_parse(syntax_snapshot);
|
||||||
self.request_autoindent(cx);
|
self.request_autoindent(cx);
|
||||||
|
@ -1968,7 +1969,12 @@ impl Buffer {
|
||||||
/// This allows downstream code to check if the buffer's text has changed without
|
/// This allows downstream code to check if the buffer's text has changed without
|
||||||
/// waiting for an effect cycle, which would be required if using eents.
|
/// waiting for an effect cycle, which would be required if using eents.
|
||||||
pub fn record_changes(&mut self, bit: rc::Weak<Cell<bool>>) {
|
pub fn record_changes(&mut self, bit: rc::Weak<Cell<bool>>) {
|
||||||
self.change_bits.push(bit);
|
if let Err(ix) = self
|
||||||
|
.change_bits
|
||||||
|
.binary_search_by_key(&rc::Weak::as_ptr(&bit), rc::Weak::as_ptr)
|
||||||
|
{
|
||||||
|
self.change_bits.insert(ix, bit);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn was_changed(&mut self) {
|
fn was_changed(&mut self) {
|
||||||
|
@ -2273,12 +2279,13 @@ impl Buffer {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn did_edit(&mut self, old_version: &clock::Global, was_dirty: bool, cx: &mut Context<Self>) {
|
fn did_edit(&mut self, old_version: &clock::Global, was_dirty: bool, cx: &mut Context<Self>) {
|
||||||
|
self.was_changed();
|
||||||
|
|
||||||
if self.edits_since::<usize>(old_version).next().is_none() {
|
if self.edits_since::<usize>(old_version).next().is_none() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
self.reparse(cx);
|
self.reparse(cx);
|
||||||
|
|
||||||
cx.emit(BufferEvent::Edited);
|
cx.emit(BufferEvent::Edited);
|
||||||
if was_dirty != self.is_dirty() {
|
if was_dirty != self.is_dirty() {
|
||||||
cx.emit(BufferEvent::DirtyChanged);
|
cx.emit(BufferEvent::DirtyChanged);
|
||||||
|
@ -2390,7 +2397,6 @@ impl Buffer {
|
||||||
}
|
}
|
||||||
self.text.apply_ops(buffer_ops);
|
self.text.apply_ops(buffer_ops);
|
||||||
self.deferred_ops.insert(deferred_ops);
|
self.deferred_ops.insert(deferred_ops);
|
||||||
self.was_changed();
|
|
||||||
self.flush_deferred_ops(cx);
|
self.flush_deferred_ops(cx);
|
||||||
self.did_edit(&old_version, was_dirty, cx);
|
self.did_edit(&old_version, was_dirty, cx);
|
||||||
// Notify independently of whether the buffer was edited as the operations could include a
|
// Notify independently of whether the buffer was edited as the operations could include a
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue