fix display map tests
These tests failed due to an indefinite hang in buffer.condition in the following code: \`\`\`rust let buffer = cx .add_model(|cx| Buffer::new(0, cx.model_id() as u64, text).with_language(language, cx)); buffer.condition(cx, |buf, _| !buf.is_parsing()).await; `\`\` In both gpui1 and gpui2 \`.with_language\` spawns a task that notifies the context once it's done. The \`condition\` waits for notifications to be raised. The gist of the problem was that in gpui2, the spawned task was scheduled straight away, so we never really saw the notification with \`condition\`, causing us to wait indefinitely. This is probably a difference in test between schedulers in gpui1 and gpui2, but I kind of sidestepped the issue by spawning a condition before firing off a parsing task with \`set_language\`.
This commit is contained in:
parent
9ffe78d264
commit
0f7fc8c1a0
3 changed files with 42 additions and 31 deletions
|
@ -1467,10 +1467,12 @@ pub mod tests {
|
|||
|
||||
cx.update(|cx| init_test(cx, |s| s.defaults.tab_size = Some(2.try_into().unwrap())));
|
||||
|
||||
let buffer = cx.build_model(|cx| {
|
||||
Buffer::new(0, cx.entity_id().as_u64(), text).with_language(language, cx)
|
||||
let buffer = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), text));
|
||||
let condition = cx.condition(&buffer, |buf, _| !buf.is_parsing());
|
||||
cx.update_model(&buffer, |this, cx| {
|
||||
this.set_language(Some(language), cx);
|
||||
});
|
||||
cx.condition(&buffer, |buf, _| !buf.is_parsing()).await;
|
||||
condition.await;
|
||||
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
|
||||
let font_size = px(14.0);
|
||||
|
@ -1554,10 +1556,12 @@ pub mod tests {
|
|||
|
||||
cx.update(|cx| init_test(cx, |_| {}));
|
||||
|
||||
let buffer = cx.build_model(|cx| {
|
||||
Buffer::new(0, cx.entity_id().as_u64(), text).with_language(language, cx)
|
||||
let buffer = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), text));
|
||||
let condition = cx.condition(&buffer, |buf, _| !buf.is_parsing());
|
||||
buffer.update(cx, |this, cx| {
|
||||
this.set_language(Some(language), cx);
|
||||
});
|
||||
cx.condition(&buffer, |buf, _| !buf.is_parsing()).await;
|
||||
condition.await;
|
||||
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
|
||||
let font_size = px(16.0);
|
||||
|
@ -1621,10 +1625,10 @@ pub mod tests {
|
|||
|
||||
let (text, highlighted_ranges) = marked_text_ranges(r#"constˇ «a»: B = "c «d»""#, false);
|
||||
|
||||
let buffer = cx.build_model(|cx| {
|
||||
Buffer::new(0, cx.entity_id().as_u64(), text).with_language(language, cx)
|
||||
});
|
||||
cx.condition(&buffer, |buf, _| !buf.is_parsing()).await;
|
||||
let buffer = cx.build_model(|cx| Buffer::new(0, cx.entity_id().as_u64(), text));
|
||||
let condition = cx.condition(&buffer, |buf, _| !buf.is_parsing());
|
||||
buffer.update(cx, |this, cx| this.set_language(Some(language), cx));
|
||||
condition.await;
|
||||
|
||||
let buffer = cx.build_model(|cx| MultiBuffer::singleton(buffer, cx));
|
||||
let buffer_snapshot = buffer.read_with(cx, |buffer, cx| buffer.snapshot(cx));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue