Fix a test flake involving zeroed out group_intervals (#20328)
Release Notes: - N/A
This commit is contained in:
parent
454c9dc06d
commit
de70852497
4 changed files with 22 additions and 7 deletions
|
@ -169,8 +169,12 @@ fn test_undo_redo_with_selection_restoration(cx: &mut TestAppContext) {
|
|||
init_test(cx, |_| {});
|
||||
|
||||
let mut now = Instant::now();
|
||||
let buffer = cx.new_model(|cx| language::Buffer::local("123456", cx));
|
||||
let group_interval = buffer.update(cx, |buffer, _| buffer.transaction_group_interval());
|
||||
let group_interval = Duration::from_millis(1);
|
||||
let buffer = cx.new_model(|cx| {
|
||||
let mut buf = language::Buffer::local("123456", cx);
|
||||
buf.set_group_interval(group_interval);
|
||||
buf
|
||||
});
|
||||
let buffer = cx.new_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let editor = cx.add_window(|cx| build_editor(buffer.clone(), cx));
|
||||
|
||||
|
|
|
@ -6482,11 +6482,21 @@ mod tests {
|
|||
fn test_history(cx: &mut AppContext) {
|
||||
let test_settings = SettingsStore::test(cx);
|
||||
cx.set_global(test_settings);
|
||||
|
||||
let buffer_1 = cx.new_model(|cx| Buffer::local("1234", cx));
|
||||
let buffer_2 = cx.new_model(|cx| Buffer::local("5678", cx));
|
||||
let group_interval: Duration = Duration::from_millis(1);
|
||||
let buffer_1 = cx.new_model(|cx| {
|
||||
let mut buf = Buffer::local("1234", cx);
|
||||
buf.set_group_interval(group_interval);
|
||||
buf
|
||||
});
|
||||
let buffer_2 = cx.new_model(|cx| {
|
||||
let mut buf = Buffer::local("5678", cx);
|
||||
buf.set_group_interval(group_interval);
|
||||
buf
|
||||
});
|
||||
let multibuffer = cx.new_model(|_| MultiBuffer::new(Capability::ReadWrite));
|
||||
let group_interval = multibuffer.read(cx).history.group_interval;
|
||||
multibuffer.update(cx, |this, _| {
|
||||
this.history.group_interval = group_interval;
|
||||
});
|
||||
multibuffer.update(cx, |multibuffer, cx| {
|
||||
multibuffer.push_excerpts(
|
||||
buffer_1.clone(),
|
||||
|
|
|
@ -608,6 +608,7 @@ fn test_history() {
|
|||
fn test_finalize_last_transaction() {
|
||||
let now = Instant::now();
|
||||
let mut buffer = Buffer::new(0, BufferId::new(1).unwrap(), "123456".into());
|
||||
buffer.history.group_interval = Duration::from_millis(1);
|
||||
|
||||
buffer.start_transaction_at(now);
|
||||
buffer.edit([(2..4, "cd")]);
|
||||
|
|
|
@ -227,7 +227,7 @@ impl History {
|
|||
if let Some(mut entry) = entries.next_back() {
|
||||
while let Some(prev_entry) = entries.next_back() {
|
||||
if !prev_entry.suppress_grouping
|
||||
&& entry.first_edit_at - prev_entry.last_edit_at <= self.group_interval
|
||||
&& entry.first_edit_at - prev_entry.last_edit_at < self.group_interval
|
||||
{
|
||||
entry = prev_entry;
|
||||
count += 1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue