Reuse Confirm action in chat panel, go-to-line, and project search

This commit is contained in:
Max Brunsfeld 2022-04-21 15:24:05 -07:00
parent 915ba91888
commit 490b65b55f
4 changed files with 25 additions and 33 deletions

View file

@ -5,13 +5,17 @@ use gpui::{
};
use settings::Settings;
use text::{Bias, Point};
use workspace::Workspace;
use workspace::{
menu::{Cancel, Confirm},
Workspace,
};
actions!(go_to_line, [Toggle, Confirm]);
actions!(go_to_line, [Toggle]);
pub fn init(cx: &mut MutableAppContext) {
cx.add_action(GoToLine::toggle);
cx.add_action(GoToLine::confirm);
cx.add_action(GoToLine::cancel);
}
pub struct GoToLine {
@ -66,6 +70,10 @@ impl GoToLine {
}
}
fn cancel(&mut self, _: &Cancel, cx: &mut ViewContext<Self>) {
cx.emit(Event::Dismissed);
}
fn confirm(&mut self, _: &Confirm, cx: &mut ViewContext<Self>) {
self.prev_scroll_position.take();
self.active_editor.update(cx, |active_editor, cx| {