diff options
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r-- | helix-term/src/commands.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index d2aa481a..fa7a4162 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -35,6 +35,7 @@ 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>, } use futures_util::FutureExt; @@ -87,6 +88,11 @@ 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 @@ -1378,7 +1384,7 @@ pub fn redo(cx: &mut Context) { pub fn yank(cx: &mut Context) { // TODO: should selections be made end inclusive? let doc = cx.doc(); - let values = doc + let values: Vec<String> = doc .selection() .fragments(doc.text().slice(..)) .map(|cow| cow.into_owned()) @@ -1386,7 +1392,11 @@ pub fn yank(cx: &mut Context) { // TODO: allow specifying reg let reg = '"'; + let msg = format!("yanked {} selection(s) to register {}", values.len(), reg); + register::set(reg, values); + + cx.set_status(msg) } pub fn paste(cx: &mut Context) { |