|
|
@ -35,6 +35,7 @@ pub struct Context<'a> {
|
|
|
|
pub callback: Option<crate::compositor::Callback>,
|
|
|
|
pub callback: Option<crate::compositor::Callback>,
|
|
|
|
pub on_next_key_callback: Option<Box<dyn FnOnce(&mut Context, KeyEvent)>>,
|
|
|
|
pub on_next_key_callback: Option<Box<dyn FnOnce(&mut Context, KeyEvent)>>,
|
|
|
|
pub callbacks: &'a mut LspCallbacks,
|
|
|
|
pub callbacks: &'a mut LspCallbacks,
|
|
|
|
|
|
|
|
pub status_msg: Option<String>,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
use futures_util::FutureExt;
|
|
|
|
use futures_util::FutureExt;
|
|
|
@ -87,6 +88,11 @@ impl<'a> Context<'a> {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
self.callbacks.push(callback);
|
|
|
|
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
|
|
|
|
/// 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) {
|
|
|
|
pub fn yank(cx: &mut Context) {
|
|
|
|
// TODO: should selections be made end inclusive?
|
|
|
|
// TODO: should selections be made end inclusive?
|
|
|
|
let doc = cx.doc();
|
|
|
|
let doc = cx.doc();
|
|
|
|
let values = doc
|
|
|
|
let values: Vec<String> = doc
|
|
|
|
.selection()
|
|
|
|
.selection()
|
|
|
|
.fragments(doc.text().slice(..))
|
|
|
|
.fragments(doc.text().slice(..))
|
|
|
|
.map(|cow| cow.into_owned())
|
|
|
|
.map(|cow| cow.into_owned())
|
|
|
@ -1386,7 +1392,11 @@ pub fn yank(cx: &mut Context) {
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: allow specifying reg
|
|
|
|
// TODO: allow specifying reg
|
|
|
|
let reg = '"';
|
|
|
|
let reg = '"';
|
|
|
|
|
|
|
|
let msg = format!("yanked {} selection(s) to register {}", values.len(), reg);
|
|
|
|
|
|
|
|
|
|
|
|
register::set(reg, values);
|
|
|
|
register::set(reg, values);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cx.set_status(msg)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn paste(cx: &mut Context) {
|
|
|
|
pub fn paste(cx: &mut Context) {
|
|
|
|