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:
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ use collections::HashMap;
|
||||
use gpui::{AppContext, Entity, ModelContext, ModelHandle, MutableAppContext, Task};
|
||||
use language::{
|
||||
Buffer, BufferChunks, BufferSnapshot, Chunk, DiagnosticEntry, Event, File, Language,
|
||||
ToOffset as _, ToPoint as _,
|
||||
ToOffset as _, ToPoint as _, TransactionId,
|
||||
};
|
||||
pub use selection::SelectionSet;
|
||||
use std::{
|
||||
@@ -206,7 +206,7 @@ impl MultiBuffer {
|
||||
&mut self,
|
||||
selection_set_ids: impl IntoIterator<Item = SelectionSetId>,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) -> Result<()> {
|
||||
) -> Option<TransactionId> {
|
||||
// TODO
|
||||
self.as_singleton()
|
||||
.unwrap()
|
||||
@@ -217,7 +217,7 @@ impl MultiBuffer {
|
||||
&mut self,
|
||||
selection_set_ids: impl IntoIterator<Item = SelectionSetId>,
|
||||
cx: &mut ModelContext<Self>,
|
||||
) -> Result<()> {
|
||||
) -> Option<TransactionId> {
|
||||
// TODO
|
||||
self.as_singleton().unwrap().update(cx, |buffer, cx| {
|
||||
buffer.end_transaction(selection_set_ids, cx)
|
||||
|
||||
Reference in New Issue
Block a user