@@ -1087,6 +1087,7 @@ fn select_regex(cx: &mut Context) {
10871087 cx,
10881088 "select:".into(),
10891089 Some(reg),
1090+ |_input: &str| Vec::new(),
10901091 move |view, doc, regex, event| {
10911092 if event != PromptEvent::Update {
10921093 return;
@@ -1109,6 +1110,7 @@ fn split_selection(cx: &mut Context) {
11091110 cx,
11101111 "split:".into(),
11111112 Some(reg),
1113+ |_input: &str| Vec::new(),
11121114 move |view, doc, regex, event| {
11131115 if event != PromptEvent::Update {
11141116 return;
@@ -1172,6 +1174,15 @@ fn search_impl(doc: &mut Document, view: &mut View, contents: &str, regex: &Rege
11721174 };
11731175}
11741176
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();
1182+ items.dedup();
1183+ items.into_iter().cloned().collect()
1184+}
1185+
11751186// TODO: use one function for search vs extend
11761187fn search(cx: &mut Context) {
11771188 let reg = cx.register.unwrap_or('/');
@@ -1182,11 +1193,19 @@ fn search(cx: &mut Context) {
11821193 // HAXX: sadly we can't avoid allocating a single string for the whole buffer since we can't
11831194 // feed chunks into the regex yet
11841195 let contents = doc.text().slice(..).to_string();
1196+ let completions = search_completions(cx, Some(reg));
11851197
11861198 let prompt = ui::regex_prompt(
11871199 cx,
11881200 "search:".into(),
11891201 Some(reg),
1202+ move |input: &str| {
1203+ completions
1204+ .iter()
1205+ .filter(|comp| comp.starts_with(input))
1206+ .map(|comp| (0.., std::borrow::Cow::Owned(comp.clone())))
1207+ .collect()
1208+ },
11901209 move |view, doc, regex, event| {
11911210 if event != PromptEvent::Update {
11921211 return;
@@ -1246,10 +1265,19 @@ fn global_search(cx: &mut Context) {
12461265 let (all_matches_sx, all_matches_rx) =
12471266 tokio::sync::mpsc::unbounded_channel::<(usize, PathBuf)>();
12481267 let smart_case = cx.editor.config.smart_case;
1268+
1269+ let completions = search_completions(cx, None);
12491270 let prompt = ui::regex_prompt(
12501271 cx,
12511272 "global search:".into(),
12521273 None,
1274+ move |input: &str| {
1275+ completions
1276+ .iter()
1277+ .filter(|comp| comp.starts_with(input))
1278+ .map(|comp| (0.., std::borrow::Cow::Owned(comp.clone())))
1279+ .collect()
1280+ },
12531281 move |_view, _doc, regex, event| {
12541282 if event != PromptEvent::Validate {
12551283 return;
@@ -4086,6 +4114,7 @@ fn keep_selections(cx: &mut Context) {
40864114 cx,
40874115 "keep:".into(),
40884116 Some(reg),
4117+ |_input: &str| Vec::new(),
40894118 move |view, doc, regex, event| {
40904119 if event != PromptEvent::Update {
40914120 return;