|
|
@ -5626,26 +5626,26 @@ fn select_textobject(cx: &mut Context, objtype: textobject::TextObject) {
|
|
|
|
cx.editor.autoinfo = Some(Info::new(title, &help_text));
|
|
|
|
cx.editor.autoinfo = Some(Info::new(title, &help_text));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn create_surround_prompt(
|
|
|
|
// fn create_surround_prompt(
|
|
|
|
editor: &Editor,
|
|
|
|
// editor: &Editor,
|
|
|
|
prefill: String,
|
|
|
|
// prefill: String,
|
|
|
|
history_register: Option<char>,
|
|
|
|
// history_register: Option<char>,
|
|
|
|
) -> Box<Prompt> {
|
|
|
|
// callback_fn: impl FnMut(&mut compositor::Context<'_>, &str, PromptEvent) + 'static,
|
|
|
|
let prompt = Prompt::new(
|
|
|
|
// ) -> Box<Prompt> {
|
|
|
|
"tag name:".into(),
|
|
|
|
// let prompt = Prompt::new(
|
|
|
|
// TODO: change this to actually be history_register
|
|
|
|
// "tag name:".into(),
|
|
|
|
Some('z'),
|
|
|
|
// // TODO: change this to actually be history_register
|
|
|
|
ui::completers::none,
|
|
|
|
// Some('z'),
|
|
|
|
move |cx: &mut compositor::Context, input: &str, event: PromptEvent| {},
|
|
|
|
// ui::completers::none,
|
|
|
|
)
|
|
|
|
// callback_fn,
|
|
|
|
.with_line("temp".into(), editor);
|
|
|
|
// )
|
|
|
|
|
|
|
|
// .with_line("temp".into(), editor);
|
|
|
|
Box::new(prompt)
|
|
|
|
|
|
|
|
}
|
|
|
|
// Box::new(prompt)
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
fn surround_add_impl(
|
|
|
|
fn surround_add_impl(
|
|
|
|
doc: &mut Document,
|
|
|
|
doc: &mut Document,
|
|
|
|
// cx: &mut Context<'_>,
|
|
|
|
|
|
|
|
view: &mut View,
|
|
|
|
view: &mut View,
|
|
|
|
surround_len: usize,
|
|
|
|
surround_len: usize,
|
|
|
|
open: Tendril,
|
|
|
|
open: Tendril,
|
|
|
@ -5671,7 +5671,6 @@ fn surround_add_impl(
|
|
|
|
let transaction = Transaction::change(doc.text(), changes.into_iter())
|
|
|
|
let transaction = Transaction::change(doc.text(), changes.into_iter())
|
|
|
|
.with_selection(Selection::new(ranges, selection.primary_index()));
|
|
|
|
.with_selection(Selection::new(ranges, selection.primary_index()));
|
|
|
|
doc.apply(&transaction, view.id);
|
|
|
|
doc.apply(&transaction, view.id);
|
|
|
|
// exit_select_mode(cx);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn surround_add(cx: &mut Context) {
|
|
|
|
fn surround_add(cx: &mut Context) {
|
|
|
@ -5680,31 +5679,23 @@ fn surround_add(cx: &mut Context) {
|
|
|
|
// surround_len is the number of new characters being added.
|
|
|
|
// surround_len is the number of new characters being added.
|
|
|
|
match event.char() {
|
|
|
|
match event.char() {
|
|
|
|
Some(ch) => {
|
|
|
|
Some(ch) => {
|
|
|
|
// let mut open = Tendril::new();
|
|
|
|
if ch == 'x' {
|
|
|
|
// let mut close = Tendril::new();
|
|
|
|
let prompt = Prompt::new(
|
|
|
|
// let length = if ch == 'x' {
|
|
|
|
"tag name:".into(),
|
|
|
|
// let prompt = create_surround_prompt(cx.editor, "none".into(), Some('z'));
|
|
|
|
Some('z'),
|
|
|
|
// cx.push_layer(prompt);
|
|
|
|
ui::completers::none,
|
|
|
|
|
|
|
|
move |cx: &mut compositor::Context, input: &str, event: PromptEvent| {},
|
|
|
|
// let (o, c) = match_brackets::get_pair(ch);
|
|
|
|
)
|
|
|
|
// open.push(o);
|
|
|
|
.with_line("temp".into(), cx.editor);
|
|
|
|
// close.push(c);
|
|
|
|
cx.push_layer(prompt);
|
|
|
|
// // Any character other than "x" will cause 2 chars to get added
|
|
|
|
} else {
|
|
|
|
// 2
|
|
|
|
let (open, close) = match_brackets::get_pair(ch);
|
|
|
|
// } else {
|
|
|
|
let open = Tendril::from(open.to_string());
|
|
|
|
let (open, close) = match_brackets::get_pair(ch);
|
|
|
|
let close = Tendril::from(close.to_string());
|
|
|
|
// open.push(o);
|
|
|
|
|
|
|
|
// close.push(c);
|
|
|
|
surround_add_impl(doc, view, 2, open, close);
|
|
|
|
// Any character other than "x" will cause 2 chars to get added
|
|
|
|
exit_select_mode(cx);
|
|
|
|
// 2
|
|
|
|
};
|
|
|
|
//
|
|
|
|
|
|
|
|
let open = Tendril::from(open.to_string());
|
|
|
|
|
|
|
|
let close = Tendril::from(close.to_string());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
surround_add_impl(doc, view, 2, open, close);
|
|
|
|
|
|
|
|
exit_select_mode(cx);
|
|
|
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
// (open, close, 2)
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
None if event.code == KeyCode::Enter => {
|
|
|
|
None if event.code == KeyCode::Enter => {
|
|
|
|
let open = doc.line_ending.as_str().into();
|
|
|
|
let open = doc.line_ending.as_str().into();
|
|
|
|