Display buffers in order of their path in refactor multibuffers
Previously, they were non-deterministically ordered via a HashMap iterator. This was causing integration tests to fail spuriously on PRs.
This commit is contained in:
parent
27e693d8f7
commit
3ad13bdd4f
2 changed files with 16 additions and 11 deletions
|
@ -3832,14 +3832,14 @@ mod tests {
|
||||||
.unwrap()
|
.unwrap()
|
||||||
});
|
});
|
||||||
code_action_editor.update(cx_b, |editor, cx| {
|
code_action_editor.update(cx_b, |editor, cx| {
|
||||||
assert_eq!(editor.text(cx), "\nmod other;\nfn main() { let foo = 4; }");
|
assert_eq!(editor.text(cx), "mod other;\nfn main() { let foo = 4; }\n");
|
||||||
editor.undo(&Undo, cx);
|
editor.undo(&Undo, cx);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
editor.text(cx),
|
editor.text(cx),
|
||||||
"pub fn foo() -> usize { 4 }\nmod other;\nfn main() { let foo = other::foo(); }"
|
"mod other;\nfn main() { let foo = other::foo(); }\npub fn foo() -> usize { 4 }"
|
||||||
);
|
);
|
||||||
editor.redo(&Redo, cx);
|
editor.redo(&Redo, cx);
|
||||||
assert_eq!(editor.text(cx), "\nmod other;\nfn main() { let foo = 4; }");
|
assert_eq!(editor.text(cx), "mod other;\nfn main() { let foo = 4; }\n");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4037,17 +4037,17 @@ mod tests {
|
||||||
rename_editor.update(cx_b, |editor, cx| {
|
rename_editor.update(cx_b, |editor, cx| {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
editor.text(cx),
|
editor.text(cx),
|
||||||
"const TWO: usize = one::THREE + one::THREE;\nconst THREE: usize = 1;"
|
"const THREE: usize = 1;\nconst TWO: usize = one::THREE + one::THREE;"
|
||||||
);
|
);
|
||||||
editor.undo(&Undo, cx);
|
editor.undo(&Undo, cx);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
editor.text(cx),
|
editor.text(cx),
|
||||||
"const TWO: usize = one::ONE + one::ONE;\nconst ONE: usize = 1;"
|
"const ONE: usize = 1;\nconst TWO: usize = one::ONE + one::ONE;"
|
||||||
);
|
);
|
||||||
editor.redo(&Redo, cx);
|
editor.redo(&Redo, cx);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
editor.text(cx),
|
editor.text(cx),
|
||||||
"const TWO: usize = one::THREE + one::THREE;\nconst THREE: usize = 1;"
|
"const THREE: usize = 1;\nconst TWO: usize = one::THREE + one::THREE;"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -2499,11 +2499,16 @@ impl Editor {
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
let replica_id = this.read_with(&cx, |this, cx| this.replica_id(cx));
|
let replica_id = this.read_with(&cx, |this, cx| this.replica_id(cx));
|
||||||
|
|
||||||
|
let mut entries = transaction.0.into_iter().collect::<Vec<_>>();
|
||||||
|
entries.sort_unstable_by_key(|(buffer, _)| {
|
||||||
|
buffer.read_with(&cx, |buffer, _| buffer.file().map(|f| f.path().clone()))
|
||||||
|
});
|
||||||
|
|
||||||
// If the project transaction's edits are all contained within this editor, then
|
// If the project transaction's edits are all contained within this editor, then
|
||||||
// avoid opening a new editor to display them.
|
// avoid opening a new editor to display them.
|
||||||
let mut entries = transaction.0.iter();
|
|
||||||
if let Some((buffer, transaction)) = entries.next() {
|
if let Some((buffer, transaction)) = entries.first() {
|
||||||
if entries.next().is_none() {
|
if entries.len() == 1 {
|
||||||
let excerpt = this.read_with(&cx, |editor, cx| {
|
let excerpt = this.read_with(&cx, |editor, cx| {
|
||||||
editor
|
editor
|
||||||
.buffer()
|
.buffer()
|
||||||
|
@ -2532,7 +2537,7 @@ impl Editor {
|
||||||
let mut ranges_to_highlight = Vec::new();
|
let mut ranges_to_highlight = Vec::new();
|
||||||
let excerpt_buffer = cx.add_model(|cx| {
|
let excerpt_buffer = cx.add_model(|cx| {
|
||||||
let mut multibuffer = MultiBuffer::new(replica_id).with_title(title);
|
let mut multibuffer = MultiBuffer::new(replica_id).with_title(title);
|
||||||
for (buffer, transaction) in &transaction.0 {
|
for (buffer, transaction) in &entries {
|
||||||
let snapshot = buffer.read(cx).snapshot();
|
let snapshot = buffer.read(cx).snapshot();
|
||||||
ranges_to_highlight.extend(
|
ranges_to_highlight.extend(
|
||||||
multibuffer.push_excerpts_with_context_lines(
|
multibuffer.push_excerpts_with_context_lines(
|
||||||
|
@ -2545,7 +2550,7 @@ impl Editor {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
multibuffer.push_transaction(&transaction.0);
|
multibuffer.push_transaction(entries.iter().map(|(b, t)| (b, t)));
|
||||||
multibuffer
|
multibuffer
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue