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

This PR replaces some `update()` calls with either `read()` or
`read_with()` when the `update()` call performed read-only operations on
the entity.

Many more likely exist, will follow-up with more PRs.

Release Notes:

- N/A
This commit is contained in:
Joseph T. Lyons 2025-05-23 06:13:49 -04:00 committed by GitHub
parent 508ccde363
commit f435304209
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 20 additions and 20 deletions

View file

@ -2397,7 +2397,7 @@ mod tests {
search_bar.replace_all(&ReplaceAll, window, cx)
});
assert_eq!(
editor.update(cx, |this, cx| { this.text(cx) }),
editor.read_with(cx, |this, cx| { this.text(cx) }),
r#"
A regular expr$1 (shortened as regex or regexp;[1] also referred to as
rational expr$1[2][3]) is a sequence of characters that specifies a search
@ -2423,7 +2423,7 @@ mod tests {
});
// Notice how the first or in the text (shORtened) is not replaced. Neither are the remaining hits of `or` in the text.
assert_eq!(
editor.update(cx, |this, cx| { this.text(cx) }),
editor.read_with(cx, |this, cx| { this.text(cx) }),
r#"
A regular expr$1 (shortened as regex banana regexp;[1] also referred to as
rational expr$1[2][3]) is a sequence of characters that specifies a search
@ -2446,7 +2446,7 @@ mod tests {
search_bar.replace_all(&ReplaceAll, window, cx)
});
assert_eq!(
editor.update(cx, |this, cx| { this.text(cx) }),
editor.read_with(cx, |this, cx| { this.text(cx) }),
r#"
A regular expr$1 (shortened as regex banana regexp;1number also referred to as
rational expr$12number3number) is a sequence of characters that specifies a search
@ -2476,7 +2476,7 @@ mod tests {
// The only word affected by this edit should be `algorithms`, even though there's a bunch
// of words in this text that would match this regex if not for WHOLE_WORD.
assert_eq!(
editor.update(cx, |this, cx| { this.text(cx) }),
editor.read_with(cx, |this, cx| { this.text(cx) }),
r#"
A regular expr$1 (shortened as regex banana regexp;1number also referred to as
rational expr$12number3number) is a sequence of characters that specifies a search
@ -2527,7 +2527,7 @@ mod tests {
assert_eq!(
options
.editor
.update(options.cx, |this, cx| { this.text(cx) }),
.read_with(options.cx, |this, cx| { this.text(cx) }),
options.expected_text
);
}