Fix race condition when opening a buffer and getting a definition to it

This commit is contained in:
Antonio Scandurra
2022-01-24 18:47:55 +01:00
parent 93125cbd16
commit 96b66dcce1
7 changed files with 160 additions and 135 deletions
+10 -6
View File
@@ -147,12 +147,9 @@ message GetDefinitionResponse {
}
message Definition {
oneof buffer {
uint64 id = 1;
Buffer state = 2;
}
Anchor target_start = 3;
Anchor target_end = 4;
Buffer buffer = 1;
Anchor target_start = 2;
Anchor target_end = 3;
}
message OpenBuffer {
@@ -324,6 +321,13 @@ message Entry {
}
message Buffer {
oneof variant {
uint64 id = 1;
BufferState state = 2;
}
}
message BufferState {
uint64 id = 1;
optional File file = 2;
string visible_text = 3;
+5 -13
View File
@@ -410,9 +410,7 @@ mod tests {
.unwrap(),
proto::OpenBufferResponse {
buffer: Some(proto::Buffer {
id: 101,
visible_text: "path/one content".to_string(),
..Default::default()
variant: Some(proto::buffer::Variant::Id(0))
}),
}
);
@@ -431,10 +429,8 @@ mod tests {
.unwrap(),
proto::OpenBufferResponse {
buffer: Some(proto::Buffer {
id: 102,
visible_text: "path/two content".to_string(),
..Default::default()
}),
variant: Some(proto::buffer::Variant::Id(1))
})
}
);
@@ -460,9 +456,7 @@ mod tests {
assert_eq!(message.worktree_id, 1);
proto::OpenBufferResponse {
buffer: Some(proto::Buffer {
id: 101,
visible_text: "path/one content".to_string(),
..Default::default()
variant: Some(proto::buffer::Variant::Id(0)),
}),
}
}
@@ -470,9 +464,7 @@ mod tests {
assert_eq!(message.worktree_id, 2);
proto::OpenBufferResponse {
buffer: Some(proto::Buffer {
id: 102,
visible_text: "path/two content".to_string(),
..Default::default()
variant: Some(proto::buffer::Variant::Id(1)),
}),
}
}