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:
parent
508ccde363
commit
f435304209
11 changed files with 20 additions and 20 deletions
|
@ -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
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue