Merge pull request #929 from zed-industries/non-uniform-batched-edits

Allow batched edits where each range is associated with different insertion text
This commit is contained in:
Keith Simmons 2022-04-29 16:14:38 -07:00 committed by GitHub
commit d4bef67cf2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 539 additions and 487 deletions

View file

@ -1710,8 +1710,8 @@ mod tests {
.update(cx_c, |p, cx| p.open_buffer((worktree_id, "file1"), cx))
.await
.unwrap();
buffer_b.update(cx_b, |buf, cx| buf.edit([0..0], "i-am-b, ", cx));
buffer_c.update(cx_c, |buf, cx| buf.edit([0..0], "i-am-c, ", cx));
buffer_b.update(cx_b, |buf, cx| buf.edit([(0..0, "i-am-b, ")], cx));
buffer_c.update(cx_c, |buf, cx| buf.edit([(0..0, "i-am-c, ")], cx));
// Open and edit that buffer as the host.
let buffer_a = project_a
@ -1723,7 +1723,7 @@ mod tests {
.condition(cx_a, |buf, _| buf.text() == "i-am-c, i-am-b, ")
.await;
buffer_a.update(cx_a, |buf, cx| {
buf.edit([buf.len()..buf.len()], "i-am-a", cx)
buf.edit([(buf.len()..buf.len(), "i-am-a")], cx)
});
// Wait for edits to propagate
@ -1739,7 +1739,7 @@ mod tests {
// Edit the buffer as the host and concurrently save as guest B.
let save_b = buffer_b.update(cx_b, |buf, cx| buf.save(cx));
buffer_a.update(cx_a, |buf, cx| buf.edit([0..0], "hi-a, ", cx));
buffer_a.update(cx_a, |buf, cx| buf.edit([(0..0, "hi-a, ")], cx));
save_b.await.unwrap();
assert_eq!(
fs.load("/a/file1".as_ref()).await.unwrap(),
@ -1869,7 +1869,7 @@ mod tests {
.await
.unwrap();
buffer_b.update(cx_b, |buf, cx| buf.edit([0..0], "world ", cx));
buffer_b.update(cx_b, |buf, cx| buf.edit([(0..0, "world ")], cx));
buffer_b.read_with(cx_b, |buf, _| {
assert!(buf.is_dirty());
assert!(!buf.has_conflict());
@ -1883,7 +1883,7 @@ mod tests {
assert!(!buf.has_conflict());
});
buffer_b.update(cx_b, |buf, cx| buf.edit([0..0], "hello ", cx));
buffer_b.update(cx_b, |buf, cx| buf.edit([(0..0, "hello ")], cx));
buffer_b.read_with(cx_b, |buf, _| {
assert!(buf.is_dirty());
assert!(!buf.has_conflict());
@ -2039,9 +2039,9 @@ mod tests {
// Edit the buffer as client A while client B is still opening it.
cx_b.background().simulate_random_delay().await;
buffer_a.update(cx_a, |buf, cx| buf.edit([0..0], "X", cx));
buffer_a.update(cx_a, |buf, cx| buf.edit([(0..0, "X")], cx));
cx_b.background().simulate_random_delay().await;
buffer_a.update(cx_a, |buf, cx| buf.edit([1..1], "Y", cx));
buffer_a.update(cx_a, |buf, cx| buf.edit([(1..1, "Y")], cx));
let text = buffer_a.read_with(cx_a, |buf, _| buf.text());
let buffer_b = buffer_b.await.unwrap();
@ -2727,8 +2727,8 @@ mod tests {
.await
.unwrap();
buffer_b.update(cx_b, |buffer, cx| {
buffer.edit([4..7], "six", cx);
buffer.edit([10..11], "6", cx);
buffer.edit([(4..7, "six")], cx);
buffer.edit([(10..11, "6")], cx);
assert_eq!(buffer.text(), "let six = 6;");
assert!(buffer.is_dirty());
assert!(!buffer.has_conflict());
@ -4009,7 +4009,7 @@ mod tests {
);
rename.editor.update(cx, |rename_editor, cx| {
rename_editor.buffer().update(cx, |rename_buffer, cx| {
rename_buffer.edit([0..3], "THREE", cx);
rename_buffer.edit([(0..3, "THREE")], cx);
});
});
});