diff options
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r-- | helix-term/src/commands.rs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index a273fc6f..eab9397c 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -42,7 +42,6 @@ pub struct Context<'a> { pub callback: Option<crate::compositor::Callback>, pub on_next_key_callback: Option<Box<dyn FnOnce(&mut Context, KeyEvent)>>, pub callbacks: &'a mut LspCallbacks, - pub status_msg: Option<String>, } impl<'a> Context<'a> { @@ -97,11 +96,6 @@ impl<'a> Context<'a> { }); self.callbacks.push(callback); } - - // TODO: allow &'static str? - pub fn set_status(&mut self, msg: String) { - self.status_msg = Some(msg); - } } /// A command is a function that takes the current state and a count, and does a side-effect on the @@ -852,6 +846,8 @@ pub fn command_mode(cx: &mut Context) { } }, // completion move |editor: &mut Editor, input: &str, event: PromptEvent| { + use helix_view::editor::Action; + if event != PromptEvent::Validate { return; } @@ -863,16 +859,20 @@ pub fn command_mode(cx: &mut Context) { editor.close(editor.view().id); } ["o", path] | ["open", path] => { - use helix_view::editor::Action; editor.open(path.into(), Action::Replace); } ["w"] | ["write"] => { - // TODO: non-blocking via save() command let id = editor.view().doc; let doc = &mut editor.documents[id]; + if doc.path().is_none() { + editor.set_error("cannot write a buffer without a filename".to_string()); + return; + } tokio::spawn(doc.save()); } - + ["new"] => { + editor.new_file(Action::Replace); + } _ => (), } }, @@ -1585,7 +1585,7 @@ pub fn yank(cx: &mut Context) { register::set(reg, values); - cx.set_status(msg) + cx.editor.set_status(msg) } #[derive(Copy, Clone)] |