@@ -1079,7 +1079,7 @@ fn select_all(cx: &mut Context) {
1081fn select_regex(cx: &mut Context) {
1081fn select_regex(cx: &mut Context) {
1082− let prompt = ui::regex_prompt(cx, "select:".to_string(), move |view, doc, _, regex| {
1082+ let prompt = ui::regex_prompt(cx, "select:".into(), move |view, doc, _, regex| {
1083 let text = doc.text().slice(..);
1083 let text = doc.text().slice(..);
1084 if let Some(selection) = selection::select_on_matches(text, doc.selection(view.id), ®ex)
1084 if let Some(selection) = selection::select_on_matches(text, doc.selection(view.id), ®ex)
@@ -1091,7 +1091,7 @@ fn select_regex(cx: &mut Context) {
1093fn split_selection(cx: &mut Context) {
1093fn split_selection(cx: &mut Context) {
1094− let prompt = ui::regex_prompt(cx, "split:".to_string(), move |view, doc, _, regex| {
1094+ let prompt = ui::regex_prompt(cx, "split:".into(), move |view, doc, _, regex| {
1095 let text = doc.text().slice(..);
1095 let text = doc.text().slice(..);
1096 let selection = selection::split_on_matches(text, doc.selection(view.id), ®ex);
1096 let selection = selection::split_on_matches(text, doc.selection(view.id), ®ex);
1097 doc.set_selection(view.id, selection);
1097 doc.set_selection(view.id, selection);
@@ -1157,15 +1157,11 @@ fn search(cx: &mut Context) {
1157 // feed chunks into the regex yet
1157 // feed chunks into the regex yet
1158 let contents = doc.text().slice(..).to_string();
1158 let contents = doc.text().slice(..).to_string();
1160− let prompt = ui::regex_prompt(
1162− "search:".to_string(),
1163− move |view, doc, registers, regex| {
1160+ let prompt = ui::regex_prompt(cx, "search:".into(), move |view, doc, registers, regex| {
1164− search_impl(doc, view, &contents, ®ex, false);
1161+ search_impl(doc, view, &contents, ®ex, false);
1165− // TODO: only store on enter (accept), not update
1162+ // TODO: only store on enter (accept), not update
1166− registers.write('/', vec![regex.as_str().to_string()]);
1163+ registers.write('/', vec![regex.as_str().to_string()]);
1170 cx.push_layer(Box::new(prompt));
1166 cx.push_layer(Box::new(prompt));
@@ -2210,7 +2206,7 @@ mod cmd {
2211fn command_mode(cx: &mut Context) {
2207fn command_mode(cx: &mut Context) {
2212 let mut prompt = Prompt::new(
2208 let mut prompt = Prompt::new(
2213− ":".to_owned(),
2209+ ":".into(),
2214 Some(':'),
2210 Some(':'),
2215 |input: &str| {
2211 |input: &str| {
2216 // we use .this over split_whitespace() because we care about empty segments
2212 // we use .this over split_whitespace() because we care about empty segments
@@ -3819,7 +3815,7 @@ fn join_selections(cx: &mut Context) {
3820fn keep_selections(cx: &mut Context) {
3816fn keep_selections(cx: &mut Context) {
3821 // keep selections matching regex
3817 // keep selections matching regex
3822− let prompt = ui::regex_prompt(cx, "keep:".to_string(), move |view, doc, _, regex| {
3818+ let prompt = ui::regex_prompt(cx, "keep:".into(), move |view, doc, _, regex| {
3823 let text = doc.text().slice(..);
3819 let text = doc.text().slice(..);
3825 if let Some(selection) = selection::keep_matches(text, doc.selection(view.id), ®ex) {
3821 if let Some(selection) = selection::keep_matches(text, doc.selection(view.id), ®ex) {
@@ -4307,26 +4303,26 @@ enum ShellBehavior {
4309fn shell_pipe(cx: &mut Context) {
4305fn shell_pipe(cx: &mut Context) {
4310− shell(cx, "pipe:", ShellBehavior::Replace);
4306+ shell(cx, "pipe:".into(), ShellBehavior::Replace);
4313fn shell_pipe_to(cx: &mut Context) {
4309fn shell_pipe_to(cx: &mut Context) {
4314− shell(cx, "pipe-to:", ShellBehavior::Ignore);
4310+ shell(cx, "pipe-to:".into(), ShellBehavior::Ignore);
4317fn shell_insert_output(cx: &mut Context) {
4313fn shell_insert_output(cx: &mut Context) {
4318− shell(cx, "insert-output:", ShellBehavior::Insert);
4314+ shell(cx, "insert-output:".into(), ShellBehavior::Insert);
4321fn shell_append_output(cx: &mut Context) {
4317fn shell_append_output(cx: &mut Context) {
4322− shell(cx, "append-output:", ShellBehavior::Append);
4318+ shell(cx, "append-output:".into(), ShellBehavior::Append);
4325fn shell_keep_pipe(cx: &mut Context) {
4321fn shell_keep_pipe(cx: &mut Context) {
4326− shell(cx, "keep-pipe:", ShellBehavior::Filter);
4322+ shell(cx, "keep-pipe:".into(), ShellBehavior::Filter);
4329−fn shell(cx: &mut Context, prompt: &str, behavior: ShellBehavior) {
4325+fn shell(cx: &mut Context, prompt: Cow<'static, str>, behavior: ShellBehavior) {
4330 use std::io::Write;
4326 use std::io::Write;
4331 use std::process::{Command, Stdio};
4327 use std::process::{Command, Stdio};
4332 if cx.editor.config.shell.is_empty() {
4328 if cx.editor.config.shell.is_empty() {
@@ -4338,7 +4334,7 @@ fn shell(cx: &mut Context, prompt: &str, behavior: ShellBehavior) {
4338 ShellBehavior::Insert | ShellBehavior::Append => false,
4334 ShellBehavior::Insert | ShellBehavior::Append => false,
4340 let prompt = Prompt::new(
4336 let prompt = Prompt::new(
4341− prompt.to_owned(),
4337+ prompt,
4342 Some('|'),
4338 Some('|'),
4343 |_input: &str| Vec::new(),
4339 |_input: &str| Vec::new(),
4344 move |cx: &mut compositor::Context, input: &str, event: PromptEvent| {
4340 move |cx: &mut compositor::Context, input: &str, event: PromptEvent| {
@@ -4408,9 +4404,8 @@ fn shell(cx: &mut Context, prompt: &str, behavior: ShellBehavior) {
4411− let transaction = Transaction::change(doc.text(), changes.into_iter());
4413 if behavior != ShellBehavior::Ignore {
4407 if behavior != ShellBehavior::Ignore {
4408+ let transaction = Transaction::change(doc.text(), changes.into_iter());
4414 doc.apply(&transaction, view.id);
4409 doc.apply(&transaction, view.id);
4415 doc.append_changes_to_history(view.id);
4410 doc.append_changes_to_history(view.id);