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

@ -841,7 +841,7 @@ impl Item for Editor {
// so that language servers or other downstream listeners of save events get notified.
let (dirty_buffers, clean_buffers) = buffers.into_iter().partition(|buffer| {
buffer
.update(cx, |buffer, _| buffer.is_dirty() || buffer.has_conflict())
.read_with(cx, |buffer, _| buffer.is_dirty() || buffer.has_conflict())
.unwrap_or(false)
});
@ -1089,7 +1089,7 @@ impl SerializableItem for Editor {
let project = project.clone();
async move |cx| {
let language_registry =
project.update(cx, |project, _| project.languages().clone())?;
project.read_with(cx, |project, _| project.languages().clone())?;
let language = if let Some(language_name) = language {
// We don't fail here, because we'd rather not set the language if the name changed
@ -2032,7 +2032,7 @@ mod tests {
{
let project = Project::test(fs.clone(), [path!("/file.rs").as_ref()], cx).await;
// Add Rust to the language, so that we can restore the language of the buffer
project.update(cx, |project, _| project.languages().add(rust_language()));
project.read_with(cx, |project, _| project.languages().add(rust_language()));
let (workspace, cx) =
cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx));