Use read-only access methods for read-only entity operations (#31479)

Another follow-up to #31254

Release Notes:

- N/A
This commit is contained in:
Joseph T. Lyons 2025-05-26 23:04:31 -04:00 committed by GitHub
parent 4a577fff4a
commit c208532693
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
79 changed files with 319 additions and 306 deletions

View file

@ -1176,7 +1176,7 @@ mod tests {
scheduled_task_label: &str,
cx: &mut VisualTestContext,
) {
let scheduled_task = tasks_picker.update(cx, |tasks_picker, _| {
let scheduled_task = tasks_picker.read_with(cx, |tasks_picker, _| {
tasks_picker
.delegate
.candidates
@ -1220,14 +1220,14 @@ mod tests {
spawn_tasks: &Entity<Picker<TasksModalDelegate>>,
cx: &mut VisualTestContext,
) -> String {
spawn_tasks.update(cx, |spawn_tasks, cx| spawn_tasks.query(cx))
spawn_tasks.read_with(cx, |spawn_tasks, cx| spawn_tasks.query(cx))
}
fn task_names(
spawn_tasks: &Entity<Picker<TasksModalDelegate>>,
cx: &mut VisualTestContext,
) -> Vec<String> {
spawn_tasks.update(cx, |spawn_tasks, _| {
spawn_tasks.read_with(cx, |spawn_tasks, _| {
spawn_tasks
.delegate
.matches

View file

@ -300,9 +300,12 @@ pub fn task_contexts(
.unwrap_or_default();
let latest_selection = active_editor.as_ref().map(|active_editor| {
active_editor.update(cx, |editor, _| {
editor.selections.newest_anchor().head().text_anchor
})
active_editor
.read(cx)
.selections
.newest_anchor()
.head()
.text_anchor
});
let mut worktree_abs_paths = workspace
@ -412,7 +415,7 @@ mod tests {
)
.await;
let project = Project::test(fs, [path!("/dir").as_ref()], cx).await;
let worktree_store = project.update(cx, |project, _| project.worktree_store().clone());
let worktree_store = project.read_with(cx, |project, _| project.worktree_store().clone());
let rust_language = Arc::new(
Language::new(
LanguageConfig::default(),