Before this change, the editor completion menu and gutter menus reversed their order so that the initial selection is near the user's focus. This change instead displays these menus in a consistent top-to-bottom order because the following benefits outweigh that benefit: * Matches behavior of some other editors (Neovim and VSCode). * Looks better for lexicographic lists. * Keeps the meaning of keyboard interaction consistent, if the user is anticipating the order of the menu's contents. Could consider making this configurable in the future if desired. Closes #25066. Release Notes: - N/A
Unified · Split
| @@ -126,16 +126,15 @@ impl CodeContextMenu { · 125 unmodified lines | ||
| 126 | 126 | &self, |
| 127 | 127 | style: &EditorStyle, |
| 128 | 128 | max_height_in_lines: u32, |
| 129 | − y_flipped: bool, | |
| 130 | 129 | window: &mut Window, |
| 131 | 130 | cx: &mut Context<Editor>, |
| 132 | 131 | ) -> AnyElement { |
| 133 | 132 | match self { |
| 134 | 133 | CodeContextMenu::Completions(menu) => { |
| 135 | − menu.render(style, max_height_in_lines, y_flipped, window, cx) | |
| 134 | + menu.render(style, max_height_in_lines, window, cx) | |
| 136 | 135 | } |
| 137 | 136 | CodeContextMenu::CodeActions(menu) => { |
| 138 | − menu.render(style, max_height_in_lines, y_flipped, window, cx) | |
| 137 | + menu.render(style, max_height_in_lines, window, cx) | |
| 139 | 138 | } |
| 140 | 139 | } |
| 141 | 140 | } |
| @@ -439,7 +438,6 @@ impl CompletionsMenu { · 297 unmodified lines | ||
| 439 | 438 | &self, |
| 440 | 439 | style: &EditorStyle, |
| 441 | 440 | max_height_in_lines: u32, |
| 442 | − y_flipped: bool, | |
| 443 | 441 | window: &mut Window, |
| 444 | 442 | cx: &mut Context<Editor>, |
| 445 | 443 | ) -> AnyElement { |
| @@ -589,7 +587,6 @@ impl CompletionsMenu { · 143 unmodified lines | ||
| 589 | 587 | .occlude() |
| 590 | 588 | .max_h(max_height_in_lines as f32 * window.line_height()) |
| 591 | 589 | .track_scroll(self.scroll_handle.clone()) |
| 592 | − .y_flipped(y_flipped) | |
| 593 | 590 | .with_width_from_item(widest_completion_ix) |
| 594 | 591 | .with_sizing_behavior(ListSizingBehavior::Infer); |
| 595 | 592 | |
| @@ -978,7 +975,6 @@ impl CodeActionsMenu { · 382 unmodified lines | ||
| 978 | 975 | &self, |
| 979 | 976 | _style: &EditorStyle, |
| 980 | 977 | max_height_in_lines: u32, |
| 981 | − y_flipped: bool, | |
| 982 | 978 | window: &mut Window, |
| 983 | 979 | cx: &mut Context<Editor>, |
| 984 | 980 | ) -> AnyElement { |
| @@ -1068,7 +1064,6 @@ impl CodeActionsMenu { · 83 unmodified lines | ||
| 1068 | 1064 | .occlude() |
| 1069 | 1065 | .max_h(max_height_in_lines as f32 * window.line_height()) |
| 1070 | 1066 | .track_scroll(self.scroll_handle.clone()) |
| 1071 | − .y_flipped(y_flipped) | |
| 1072 | 1067 | .with_width_from_item( |
| 1073 | 1068 | self.actions |
| 1074 | 1069 | .iter() |
| @@ -7702,7 +7702,6 @@ impl Editor { · 7701 unmodified lines | ||
| 7702 | 7702 | &self, |
| 7703 | 7703 | style: &EditorStyle, |
| 7704 | 7704 | max_height_in_lines: u32, |
| 7705 | − y_flipped: bool, | |
| 7706 | 7705 | window: &mut Window, |
| 7707 | 7706 | cx: &mut Context<Editor>, |
| 7708 | 7707 | ) -> Option<AnyElement> { |
| @@ -7711,7 +7710,7 @@ impl Editor { · 2 unmodified lines | ||
| 7711 | 7710 | if !menu.visible() { |
| 7712 | 7711 | return None; |
| 7713 | 7712 | }; |
| 7714 | − Some(menu.render(style, max_height_in_lines, y_flipped, window, cx)) | |
| 7713 | + Some(menu.render(style, max_height_in_lines, window, cx)) | |
| 7715 | 7714 | } |
| 7716 | 7715 | |
| 7717 | 7716 | fn render_context_menu_aside( |
| @@ -3351,7 +3351,7 @@ impl EditorElement { · 3350 unmodified lines | ||
| 3351 | 3351 | height - height_above_menu |
| 3352 | 3352 | }; |
| 3353 | 3353 | let mut element = self |
| 3354 | − .render_context_menu(line_height, menu_height, y_flipped, window, cx) | |
| 3354 | + .render_context_menu(line_height, menu_height, window, cx) | |
| 3355 | 3355 | .expect("Visible context menu should always render."); |
| 3356 | 3356 | let size = element.layout_as_root(AvailableSpace::min_size(), window, cx); |
| 3357 | 3357 | Some((CursorPopoverType::CodeContextMenu, element, size)) |
| @@ -3508,9 +3508,9 @@ impl EditorElement { · 150 unmodified lines | ||
| 3508 | 3508 | viewport_bounds, |
| 3509 | 3509 | window, |
| 3510 | 3510 | cx, |
| 3511 | − move |height, _max_width_for_stable_x, y_flipped, window, cx| { | |
| 3511 | + move |height, _max_width_for_stable_x, _, window, cx| { | |
| 3512 | 3512 | let mut element = self |
| 3513 | − .render_context_menu(line_height, height, y_flipped, window, cx) | |
| 3513 | + .render_context_menu(line_height, height, window, cx) | |
| 3514 | 3514 | .expect("Visible context menu should always render."); |
| 3515 | 3515 | let size = element.layout_as_root(AvailableSpace::min_size(), window, cx); |
| 3516 | 3516 | vec![(CursorPopoverType::CodeContextMenu, element, size)] |
| @@ -3740,13 +3740,12 @@ impl EditorElement { · 223 unmodified lines | ||
| 3740 | 3740 | &self, |
| 3741 | 3741 | line_height: Pixels, |
| 3742 | 3742 | height: Pixels, |
| 3743 | − y_flipped: bool, | |
| 3744 | 3743 | window: &mut Window, |
| 3745 | 3744 | cx: &mut App, |
| 3746 | 3745 | ) -> Option<AnyElement> { |
| 3747 | 3746 | let max_height_in_lines = ((height - POPOVER_Y_PADDING) / line_height).floor() as u32; |
| 3748 | 3747 | self.editor.update(cx, |editor, cx| { |
| 3749 | − editor.render_context_menu(&self.style, max_height_in_lines, y_flipped, window, cx) | |
| 3748 | + editor.render_context_menu(&self.style, max_height_in_lines, window, cx) | |
| 3750 | 3749 | }) |
| 3751 | 3750 | } |
| 3752 | 3751 | |