@@ -248,6 +248,39 @@ pub fn extend_line_down(cx: &mut Context) {
248248 cx.view.doc.set_selection(selection);
249249}
250250
251+pub fn split_selection(cx: &mut Context) {
252+ // TODO: this needs to store initial selection state, revert on esc, confirm on enter
253+ // needs to also call the callback function per input change, not just final time.
254+ // could cheat and put it into completion_fn
255+ //
256+ // kakoune does it like this:
257+ // # save state to register
258+ // {
259+ // # restore state from register
260+ // # if event == abort, return early
261+ // # add to history if enabled
262+ // # update state
263+ // }
264+
265+ let prompt = Prompt::new(
266+ "split:".to_string(),
267+ |input: &str| Vec::new(), // TODO: use Option here?
268+ |editor: &mut Editor, input: &str| {
269+ match Regex::new(input) {
270+ Ok(regex) => {
271+ let view = editor.view_mut().unwrap();
272+ let text = &view.doc.text().slice(..);
273+ let selection = selection::split_on_matches(text, view.doc.selection(), ®ex);
274+ view.doc.set_selection(selection);
275+ }
276+ Err(_) => (), // TODO: mark command line as error
277+ }
278+ },
279+ );
280+
281+ unimplemented!()
282+}
283+
251284pub fn split_selection_on_newline(cx: &mut Context) {
252285 let text = &cx.view.doc.text().slice(..);
253286 // only compile the regex once