aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2022-03-22 14:25:40 +0000
committerBlaž Hrastnik2022-03-28 02:02:21 +0000
commit96a4eb84838d4cbfb9313968278985ea1986a3bc (patch)
tree24506b4194cae8028130727933be8c640b7e54cf /helix-term/src/commands.rs
parent5c162ef995e3822cd465f2c83874a040ebe153b8 (diff)
Remove more push_layer calls
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs35
1 files changed, 15 insertions, 20 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 7de4d7eb..01d20b28 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -2187,7 +2187,7 @@ async fn make_format_callback(
format: impl Future<Output = helix_lsp::util::LspFormatting> + Send + 'static,
) -> anyhow::Result<job::Callback> {
let format = format.await;
- let call: job::Callback = Box::new(move |editor: &mut Editor, _compositor: &mut Compositor| {
+ let call: job::Callback = Box::new(move |editor, _compositor| {
let view_id = view!(editor).id;
if let Some(doc) = editor.document_mut(doc_id) {
if doc.version() == doc_version {
@@ -3475,9 +3475,7 @@ pub fn completion(cx: &mut Context) {
cx.callback(
future,
- move |editor: &mut Editor,
- compositor: &mut Compositor,
- response: Option<lsp::CompletionResponse>| {
+ move |editor, compositor, response: Option<lsp::CompletionResponse>| {
let doc = doc!(editor);
if doc.mode() != Mode::Insert {
// we're not in insert mode anymore
@@ -4123,11 +4121,12 @@ fn shell_append_output(cx: &mut Context) {
}
fn shell_keep_pipe(cx: &mut Context) {
- let prompt = Prompt::new(
+ ui::prompt(
+ cx,
"keep-pipe:".into(),
Some('|'),
ui::completers::none,
- move |cx: &mut compositor::Context, input: &str, event: PromptEvent| {
+ move |cx, input: &str, event: PromptEvent| {
let shell = &cx.editor.config().shell;
if event != PromptEvent::Validate {
return;
@@ -4171,8 +4170,6 @@ fn shell_keep_pipe(cx: &mut Context) {
doc.set_selection(view.id, Selection::new(ranges, index));
},
);
-
- cx.push_layer(Box::new(prompt));
}
fn shell_impl(
@@ -4219,11 +4216,13 @@ fn shell(cx: &mut Context, prompt: Cow<'static, str>, behavior: ShellBehavior) {
ShellBehavior::Replace | ShellBehavior::Ignore => true,
ShellBehavior::Insert | ShellBehavior::Append => false,
};
- let prompt = Prompt::new(
+
+ ui::prompt(
+ cx,
prompt,
Some('|'),
ui::completers::none,
- move |cx: &mut compositor::Context, input: &str, event: PromptEvent| {
+ move |cx, input: &str, event: PromptEvent| {
let config = cx.editor.config();
let shell = &config.shell;
if event != PromptEvent::Validate {
@@ -4273,8 +4272,6 @@ fn shell(cx: &mut Context, prompt: Cow<'static, str>, behavior: ShellBehavior) {
view.ensure_cursor_in_view(doc, config.scrolloff);
},
);
-
- cx.push_layer(Box::new(prompt));
}
fn suspend(_cx: &mut Context) {
@@ -4420,13 +4417,11 @@ fn replay_macro(cx: &mut Context) {
};
let count = cx.count();
- cx.callback = Some(Box::new(
- move |compositor: &mut Compositor, cx: &mut compositor::Context| {
- for _ in 0..count {
- for &key in keys.iter() {
- compositor.handle_event(crossterm::event::Event::Key(key.into()), cx);
- }
+ cx.callback = Some(Box::new(move |compositor, cx| {
+ for _ in 0..count {
+ for &key in keys.iter() {
+ compositor.handle_event(crossterm::event::Event::Key(key.into()), cx);
}
- },
- ));
+ }
+ }));
}