Return optional transaction ids when starting/ending a transaction

If the transaction was nested, we return None. Otherwise we return the transaction id in preparation for editors to maintain their own selection state.
This commit is contained in:
Nathan Sobo 2021-12-10 18:00:09 -07:00
parent c8b43e3078
commit 77defe6e28
6 changed files with 65 additions and 52 deletions

View file

@ -25,11 +25,10 @@ use language::{
BracketPair, Buffer, Diagnostic, DiagnosticSeverity, Language, Point, Selection, SelectionGoal,
SelectionSetId,
};
use multi_buffer::{
Anchor, AnchorRangeExt, MultiBufferChunks, MultiBufferSnapshot,
SelectionSet, ToOffset, ToPoint,
};
pub use multi_buffer::MultiBuffer;
use multi_buffer::{
Anchor, AnchorRangeExt, MultiBufferChunks, MultiBufferSnapshot, SelectionSet, ToOffset, ToPoint,
};
use serde::{Deserialize, Serialize};
use smallvec::SmallVec;
use smol::Timer;
@ -3209,15 +3208,13 @@ impl Editor {
fn start_transaction(&mut self, cx: &mut ViewContext<Self>) {
self.end_selection(cx);
self.buffer.update(cx, |buffer, cx| {
buffer
.start_transaction([self.selection_set_id], cx)
.unwrap()
buffer.start_transaction([self.selection_set_id], cx);
});
}
fn end_transaction(&self, cx: &mut ViewContext<Self>) {
self.buffer.update(cx, |buffer, cx| {
buffer.end_transaction([self.selection_set_id], cx).unwrap()
buffer.end_transaction([self.selection_set_id], cx);
});
}