mirror of https://github.com/helix-editor/helix
split_selection
parent
f92998a14b
commit
2bfdcede32
|
@ -262,15 +262,17 @@ pub fn split_selection(cx: &mut Context) {
|
||||||
// # update state
|
// # update state
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
cx.callback = Some(Box::new(|compositor: &mut Compositor| {
|
||||||
let prompt = Prompt::new(
|
let prompt = Prompt::new(
|
||||||
"split:".to_string(),
|
"split:".to_string(),
|
||||||
|input: &str| Vec::new(), // TODO: use Option here?
|
|input: &str| Vec::new(), // this is fine because Vec::new() doesn't allocate
|
||||||
|editor: &mut Editor, input: &str| {
|
|editor: &mut Editor, input: &str| {
|
||||||
match Regex::new(input) {
|
match Regex::new(input) {
|
||||||
Ok(regex) => {
|
Ok(regex) => {
|
||||||
let view = editor.view_mut().unwrap();
|
let view = editor.view_mut().unwrap();
|
||||||
let text = &view.doc.text().slice(..);
|
let text = &view.doc.text().slice(..);
|
||||||
let selection = selection::split_on_matches(text, view.doc.selection(), ®ex);
|
let selection =
|
||||||
|
selection::split_on_matches(text, view.doc.selection(), ®ex);
|
||||||
view.doc.set_selection(selection);
|
view.doc.set_selection(selection);
|
||||||
}
|
}
|
||||||
Err(_) => (), // TODO: mark command line as error
|
Err(_) => (), // TODO: mark command line as error
|
||||||
|
@ -278,7 +280,8 @@ pub fn split_selection(cx: &mut Context) {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
unimplemented!()
|
compositor.push(Box::new(prompt));
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn split_selection_on_newline(cx: &mut Context) {
|
pub fn split_selection_on_newline(cx: &mut Context) {
|
||||||
|
|
|
@ -156,8 +156,8 @@ pub fn default() -> Keymaps {
|
||||||
vec![key!('o')] => commands::open_below,
|
vec![key!('o')] => commands::open_below,
|
||||||
vec![key!('d')] => commands::delete_selection,
|
vec![key!('d')] => commands::delete_selection,
|
||||||
vec![key!('c')] => commands::change_selection,
|
vec![key!('c')] => commands::change_selection,
|
||||||
vec![shift!('S')] => commands::split_selection,
|
|
||||||
vec![key!('s')] => commands::split_selection_on_newline,
|
vec![key!('s')] => commands::split_selection_on_newline,
|
||||||
|
vec![shift!('S')] => commands::split_selection,
|
||||||
vec![key!(';')] => commands::collapse_selection,
|
vec![key!(';')] => commands::collapse_selection,
|
||||||
// TODO should be alt(;)
|
// TODO should be alt(;)
|
||||||
vec![key!('%')] => commands::flip_selections,
|
vec![key!('%')] => commands::flip_selections,
|
||||||
|
|
Loading…
Reference in New Issue