docs(gpui): correct async and test context docs - #83
Merged
Merged
Conversation
contexts.md said every async entity call is fallible and that TestAppContext panics when the app or window is missing. Entity::update on AsyncApp panics if the app is gone. Window updates return Result. TestAppContext owns the app, and its update_window returns Result.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
crates/moon-gpui/docs/contexts.mddescribed async and test contexts in a way the code does not.to_asyncmakes entity calls fallible because the context can outlive the app.AsyncAppholds a weak app reference.Entity::updateon that context panics if the app is already gone (app().expect(...)) and does not returnResult.AsyncApp::update_windowandAsyncWindowContext::updatereturnResultwhen the app was dropped, the app is quitting, or the window is gone.TestAppContextpanics on a missing app or window. The context owns the app throughRc.TestAppContext::update_windowreturnsResultwhen the window is gone.VisualTestContext::updateunwraps that result and panics.WindowHandle::updateyields aWindow. The method takes anAppContextand a closureFnOnce(&mut V, &mut Window, &mut Context<V>) -> Rand returnsResult.How to verify
Markdown only. Compared the new sentences with
App::to_async,Window::to_async,Context::spawn/spawn_in,AsyncApp::update_entity/update_window,AsyncWindowContext::update,Entity::update,WeakEntity::update,TestAppContext,VisualTestContext::update, andWindowHandle::update.A clean-context review disputed three claims. Those parts were dropped or narrowed before push, and the diff was not sent back for a second reading:
Context<T>does not lackto_async. It dereferences toApp, socx.to_async()isApp::to_async.AsyncAppmethod panics. The panic claim is limited toEntity::update. Window updates returnResult, including when the app was released.TestAppContexthas no clock helpers of its own.advance_clocklives onBackgroundExecutor. The clock sentence was removed.