Use read() over read_with() to improve readability in simple cases (#31455)

Follow up to: #31263 

Release Notes:

- N/A
This commit is contained in:
Joseph T. Lyons 2025-05-26 16:14:07 -04:00 committed by GitHub
parent 5bafb2b160
commit 534bb0620d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 80 additions and 94 deletions

View file

@ -1533,9 +1533,7 @@ impl EditorElement {
window: &mut Window,
cx: &mut App,
) -> Option<MinimapLayout> {
let minimap_editor = self
.editor
.read_with(cx, |editor, _| editor.minimap().cloned())?;
let minimap_editor = self.editor.read(cx).minimap().cloned()?;
let minimap_settings = EditorSettings::get_global(cx).minimap;
@ -1581,12 +1579,10 @@ impl EditorElement {
);
let minimap_line_height = self.get_minimap_line_height(
minimap_editor
.read_with(cx, |editor, _| {
editor
.text_style_refinement
.as_ref()
.and_then(|refinement| refinement.font_size)
})
.read(cx)
.text_style_refinement
.as_ref()
.and_then(|refinement| refinement.font_size)
.unwrap_or(MINIMAP_FONT_SIZE),
window,
cx,
@ -7562,14 +7558,14 @@ impl Element for EditorElement {
let scrollbars_shown = settings.scrollbar.show != ShowScrollbar::Never;
let vertical_scrollbar_width = (scrollbars_shown
&& settings.scrollbar.axes.vertical
&& self
.editor
.read_with(cx, |editor, _| editor.show_scrollbars))
.then_some(style.scrollbar_width)
.unwrap_or_default();
&& self.editor.read(cx).show_scrollbars)
.then_some(style.scrollbar_width)
.unwrap_or_default();
let minimap_width = self
.editor
.read_with(cx, |editor, _| editor.minimap().is_some())
.read(cx)
.minimap()
.is_some()
.then(|| match settings.minimap.show {
ShowMinimap::Auto => {
scrollbars_shown.then_some(MinimapLayout::MINIMAP_WIDTH)