@@ -1087,6 +1087,7 @@ fn select_regex(cx: &mut Context) {
1088 "select:".into(),
1088 "select:".into(),
1089 Some(reg),
1089 Some(reg),
1090+ |_input: &str| Vec::new(),
1090 move |view, doc, regex, event| {
1091 move |view, doc, regex, event| {
1091 if event != PromptEvent::Update {
1092 if event != PromptEvent::Update {
@@ -1109,6 +1110,7 @@ fn split_selection(cx: &mut Context) {
1110 "split:".into(),
1111 "split:".into(),
1111 Some(reg),
1112 Some(reg),
1113+ |_input: &str| Vec::new(),
1112 move |view, doc, regex, event| {
1114 move |view, doc, regex, event| {
1113 if event != PromptEvent::Update {
1115 if event != PromptEvent::Update {
@@ -1172,6 +1174,15 @@ fn search_impl(doc: &mut Document, view: &mut View, contents: &str, regex: &Rege
1177+fn search_completions(cx: &mut Context, reg: Option<char>) -> Vec<String> {
1178+ let mut items = reg
1179+ .and_then(|reg| cx.editor.registers.get(reg))
1180+ .map_or(Vec::new(), |reg| reg.read().iter().take(200).collect());
1181+ items.sort_unstable();
1183+ items.into_iter().cloned().collect()
1175// TODO: use one function for search vs extend
1186// TODO: use one function for search vs extend
1176fn search(cx: &mut Context) {
1187fn search(cx: &mut Context) {
1177 let reg = cx.register.unwrap_or('/');
1188 let reg = cx.register.unwrap_or('/');
@@ -1182,11 +1193,19 @@ fn search(cx: &mut Context) {
1182 // HAXX: sadly we can't avoid allocating a single string for the whole buffer since we can't
1193 // HAXX: sadly we can't avoid allocating a single string for the whole buffer since we can't
1183 // feed chunks into the regex yet
1194 // feed chunks into the regex yet
1184 let contents = doc.text().slice(..).to_string();
1195 let contents = doc.text().slice(..).to_string();
1196+ let completions = search_completions(cx, Some(reg));
1186 let prompt = ui::regex_prompt(
1198 let prompt = ui::regex_prompt(
1188 "search:".into(),
1200 "search:".into(),
1189 Some(reg),
1201 Some(reg),
1202+ move |input: &str| {
1205+ .filter(|comp| comp.starts_with(input))
1206+ .map(|comp| (0.., std::borrow::Cow::Owned(comp.clone())))
1190 move |view, doc, regex, event| {
1209 move |view, doc, regex, event| {
1191 if event != PromptEvent::Update {
1210 if event != PromptEvent::Update {
@@ -1246,10 +1265,19 @@ fn global_search(cx: &mut Context) {
1246 let (all_matches_sx, all_matches_rx) =
1265 let (all_matches_sx, all_matches_rx) =
1247 tokio::sync::mpsc::unbounded_channel::<(usize, PathBuf)>();
1266 tokio::sync::mpsc::unbounded_channel::<(usize, PathBuf)>();
1248 let smart_case = cx.editor.config.smart_case;
1267 let smart_case = cx.editor.config.smart_case;
1269+ let completions = search_completions(cx, None);
1249 let prompt = ui::regex_prompt(
1270 let prompt = ui::regex_prompt(
1251 "global search:".into(),
1272 "global search:".into(),
1274+ move |input: &str| {
1277+ .filter(|comp| comp.starts_with(input))
1278+ .map(|comp| (0.., std::borrow::Cow::Owned(comp.clone())))
1253 move |_view, _doc, regex, event| {
1281 move |_view, _doc, regex, event| {
1254 if event != PromptEvent::Validate {
1282 if event != PromptEvent::Validate {
@@ -4086,6 +4114,7 @@ fn keep_selections(cx: &mut Context) {
4087 "keep:".into(),
4115 "keep:".into(),
4088 Some(reg),
4116 Some(reg),
4117+ |_input: &str| Vec::new(),
4089 move |view, doc, regex, event| {
4118 move |view, doc, regex, event| {
4090 if event != PromptEvent::Update {
4119 if event != PromptEvent::Update {