Skip to content

Commit c44db3b

Browse files
committed
Confirm code action on mouse down
1 parent fb450e3 commit c44db3b

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

crates/editor2/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ snippet = { path = "../snippet" }
4444
sum_tree = { path = "../sum_tree" }
4545
text = { package="text2", path = "../text2" }
4646
theme = { package="theme2", path = "../theme2" }
47-
ui2 = { package = "ui2", path = "../ui2" }
47+
ui = { package = "ui2", path = "../ui2" }
4848
util = { path = "../util" }
4949
sqlez = { path = "../sqlez" }
5050
workspace = { package = "workspace2", path = "../workspace2" }

crates/editor2/src/editor.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ use gpui::{
4242
action, actions, div, point, px, relative, rems, size, uniform_list, AnyElement, AppContext,
4343
AsyncWindowContext, BackgroundExecutor, Bounds, ClipboardItem, Component, Context,
4444
DispatchContext, EventEmitter, FocusHandle, FontFeatures, FontStyle, FontWeight,
45-
HighlightStyle, Hsla, InputHandler, Model, ParentElement, Pixels, Render, StatelessInteractive,
46-
Styled, Subscription, Task, TextStyle, UniformListScrollHandle, View, ViewContext,
47-
VisualContext, WeakView, WindowContext,
45+
HighlightStyle, Hsla, InputHandler, Model, MouseButton, ParentElement, Pixels, Render,
46+
StatelessInteractive, Styled, Subscription, Task, TextStyle, UniformListScrollHandle, View,
47+
ViewContext, VisualContext, WeakView, WindowContext,
4848
};
4949
use highlight_matching_bracket::refresh_matching_bracket_highlights;
5050
use hover_popover::{hide_hover, HoverState};
@@ -1586,6 +1586,17 @@ impl CodeActionsMenu {
15861586
.bg(colors.element_hover)
15871587
.text_color(colors.text_accent)
15881588
})
1589+
.on_mouse_down(MouseButton::Left, move |editor: &mut Editor, _, cx| {
1590+
cx.stop_propagation();
1591+
editor
1592+
.confirm_code_action(
1593+
&ConfirmCodeAction {
1594+
item_ix: Some(item_ix),
1595+
},
1596+
cx,
1597+
)
1598+
.map(|task| task.detach_and_log_err(cx));
1599+
})
15891600
.child(action.lsp_action.title.clone())
15901601
})
15911602
.collect()
@@ -4429,7 +4440,7 @@ impl Editor {
44294440
) -> Option<AnyElement<Self>> {
44304441
if self.available_code_actions.is_some() {
44314442
Some(
4432-
IconButton::new("code_actions_indicator", ui2::Icon::Bolt)
4443+
IconButton::new("code_actions_indicator", ui::Icon::Bolt)
44334444
.on_click(|editor: &mut Editor, cx| {
44344445
editor.toggle_code_actions(
44354446
&ToggleCodeActions {

0 commit comments

Comments
 (0)