@@ -262,23 +262,26 @@ pub fn split_selection(cx: &mut Context) {
262 // # update state
262 // # update state
265+ cx.callback = Some(Box::new(|compositor: &mut Compositor| {
265− let prompt = Prompt::new(
266+ let prompt = Prompt::new(
266− "split:".to_string(),
267+ "split:".to_string(),
267− |input: &str| Vec::new(), // TODO: use Option here?
268+ |input: &str| Vec::new(), // this is fine because Vec::new() doesn't allocate
268− |editor: &mut Editor, input: &str| {
269+ |editor: &mut Editor, input: &str| {
269− match Regex::new(input) {
270+ match Regex::new(input) {
270− Ok(regex) => {
271+ Ok(regex) => {
271− let view = editor.view_mut().unwrap();
272+ let view = editor.view_mut().unwrap();
272− let text = &view.doc.text().slice(..);
273+ let text = &view.doc.text().slice(..);
273− let selection = selection::split_on_matches(text, view.doc.selection(), ®ex);
275+ selection::split_on_matches(text, view.doc.selection(), ®ex);
274− view.doc.set_selection(selection);
276+ view.doc.set_selection(selection);
278+ Err(_) => (), // TODO: mark command line as error
276− Err(_) => (), // TODO: mark command line as error
281− unimplemented!()
283+ compositor.push(Box::new(prompt));
284pub fn split_selection_on_newline(cx: &mut Context) {
287pub fn split_selection_on_newline(cx: &mut Context) {