@@ -1310,6 +1310,7 @@ fn global_search(cx: &mut Context) {
1311 cx.push_layer(Box::new(prompt));
1311 cx.push_layer(Box::new(prompt));
1313+ let root = find_root(None).unwrap_or_else(|| PathBuf::from("./"));
1313 let show_picker = async move {
1314 let show_picker = async move {
1314 let all_matches: Vec<(usize, PathBuf)> =
1315 let all_matches: Vec<(usize, PathBuf)> =
1315 UnboundedReceiverStream::new(all_matches_rx).collect().await;
1316 UnboundedReceiverStream::new(all_matches_rx).collect().await;
@@ -1321,7 +1322,13 @@ fn global_search(cx: &mut Context) {
1322 let picker = FilePicker::new(
1323 let picker = FilePicker::new(
1323 all_matches,
1324 all_matches,
1324− move |(_line_num, path)| path.to_str().unwrap().into(),
1325+ move |(_line_num, path)| {
1326+ path.strip_prefix(&root)
1325 move |editor: &mut Editor, (line_num, path), action| {
1332 move |editor: &mut Editor, (line_num, path), action| {
1326 match editor.open(path.into(), action) {
1333 match editor.open(path.into(), action) {
1327 Ok(_) => {}
1334 Ok(_) => {}
@@ -1504,7 +1511,7 @@ mod cmd {
1504 #[derive(Clone)]
1511 #[derive(Clone)]
1505 pub struct TypableCommand {
1512 pub struct TypableCommand {
1506 pub name: &'static str,
1513 pub name: &'static str,
1507− pub alias: Option<&'static str>,
1514+ pub aliases: &'static [&'static str],
1508 pub doc: &'static str,
1515 pub doc: &'static str,
1509 // params, flags, helper, completer
1516 // params, flags, helper, completer
1510 pub fun: fn(&mut compositor::Context, &[&str], PromptEvent) -> anyhow::Result<()>,
1517 pub fun: fn(&mut compositor::Context, &[&str], PromptEvent) -> anyhow::Result<()>,
@@ -2178,238 +2185,238 @@ mod cmd {
2178 pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
2185 pub const TYPABLE_COMMAND_LIST: &[TypableCommand] = &[
2179 TypableCommand {
2186 TypableCommand {
2180 name: "quit",
2187 name: "quit",
2181− alias: Some("q"),
2188+ aliases: &["q"],
2182 doc: "Close the current view.",
2189 doc: "Close the current view.",
2183 fun: quit,
2190 fun: quit,
2184 completer: None,
2191 completer: None,
2186 TypableCommand {
2193 TypableCommand {
2187 name: "quit!",
2194 name: "quit!",
2188− alias: Some("q!"),
2195+ aliases: &["q!"],
2189 doc: "Close the current view.",
2196 doc: "Close the current view.",
2190 fun: force_quit,
2197 fun: force_quit,
2191 completer: None,
2198 completer: None,
2193 TypableCommand {
2200 TypableCommand {
2194 name: "open",
2201 name: "open",
2195− alias: Some("o"),
2202+ aliases: &["o"],
2196 doc: "Open a file from disk into the current view.",
2203 doc: "Open a file from disk into the current view.",
2197 fun: open,
2204 fun: open,
2198 completer: Some(completers::filename),
2205 completer: Some(completers::filename),
2200 TypableCommand {
2207 TypableCommand {
2201 name: "write",
2208 name: "write",
2202− alias: Some("w"),
2209+ aliases: &["w"],
2203 doc: "Write changes to disk. Accepts an optional path (:write some/path.txt)",
2210 doc: "Write changes to disk. Accepts an optional path (:write some/path.txt)",
2204 fun: write,
2211 fun: write,
2205 completer: Some(completers::filename),
2212 completer: Some(completers::filename),
2207 TypableCommand {
2214 TypableCommand {
2208 name: "new",
2215 name: "new",
2209− alias: Some("n"),
2216+ aliases: &["n"],
2210 doc: "Create a new scratch buffer.",
2217 doc: "Create a new scratch buffer.",
2211 fun: new_file,
2218 fun: new_file,
2212 completer: Some(completers::filename),
2219 completer: Some(completers::filename),
2214 TypableCommand {
2221 TypableCommand {
2215 name: "format",
2222 name: "format",
2216− alias: Some("fmt"),
2223+ aliases: &["fmt"],
2217 doc: "Format the file using a formatter.",
2224 doc: "Format the file using a formatter.",
2218 fun: format,
2225 fun: format,
2219 completer: None,
2226 completer: None,
2221 TypableCommand {
2228 TypableCommand {
2222 name: "indent-style",
2229 name: "indent-style",
2223− alias: None,
2230+ aliases: &[],
2224 doc: "Set the indentation style for editing. ('t' for tabs or 1-8 for number of spaces.)",
2231 doc: "Set the indentation style for editing. ('t' for tabs or 1-8 for number of spaces.)",
2225 fun: set_indent_style,
2232 fun: set_indent_style,
2226 completer: None,
2233 completer: None,
2228 TypableCommand {
2235 TypableCommand {
2229 name: "line-ending",
2236 name: "line-ending",
2230− alias: None,
2237+ aliases: &[],
2231 doc: "Set the document's default line ending. Options: crlf, lf, cr, ff, nel.",
2238 doc: "Set the document's default line ending. Options: crlf, lf, cr, ff, nel.",
2232 fun: set_line_ending,
2239 fun: set_line_ending,
2233 completer: None,
2240 completer: None,
2235 TypableCommand {
2242 TypableCommand {
2236 name: "earlier",
2243 name: "earlier",
2237− alias: Some("ear"),
2244+ aliases: &["ear"],
2238 doc: "Jump back to an earlier point in edit history. Accepts a number of steps or a time span.",
2245 doc: "Jump back to an earlier point in edit history. Accepts a number of steps or a time span.",
2239 fun: earlier,
2246 fun: earlier,
2240 completer: None,
2247 completer: None,
2242 TypableCommand {
2249 TypableCommand {
2243 name: "later",
2250 name: "later",
2244− alias: Some("lat"),
2251+ aliases: &["lat"],
2245 doc: "Jump to a later point in edit history. Accepts a number of steps or a time span.",
2252 doc: "Jump to a later point in edit history. Accepts a number of steps or a time span.",
2246 fun: later,
2253 fun: later,
2247 completer: None,
2254 completer: None,
2249 TypableCommand {
2256 TypableCommand {
2250 name: "write-quit",
2257 name: "write-quit",
2251− alias: Some("wq"),
2258+ aliases: &["wq", "x"],
2252 doc: "Writes changes to disk and closes the current view. Accepts an optional path (:wq some/path.txt)",
2259 doc: "Writes changes to disk and closes the current view. Accepts an optional path (:wq some/path.txt)",
2253 fun: write_quit,
2260 fun: write_quit,
2254 completer: Some(completers::filename),
2261 completer: Some(completers::filename),
2256 TypableCommand {
2263 TypableCommand {
2257 name: "write-quit!",
2264 name: "write-quit!",
2258− alias: Some("wq!"),
2265+ aliases: &["wq!", "x!"],
2259 doc: "Writes changes to disk and closes the current view forcefully. Accepts an optional path (:wq! some/path.txt)",
2266 doc: "Writes changes to disk and closes the current view forcefully. Accepts an optional path (:wq! some/path.txt)",
2260 fun: force_write_quit,
2267 fun: force_write_quit,
2261 completer: Some(completers::filename),
2268 completer: Some(completers::filename),
2263 TypableCommand {
2270 TypableCommand {
2264 name: "write-all",
2271 name: "write-all",
2265− alias: Some("wa"),
2272+ aliases: &["wa"],
2266 doc: "Writes changes from all views to disk.",
2273 doc: "Writes changes from all views to disk.",
2267 fun: write_all,
2274 fun: write_all,
2268 completer: None,
2275 completer: None,
2270 TypableCommand {
2277 TypableCommand {
2271 name: "write-quit-all",
2278 name: "write-quit-all",
2272− alias: Some("wqa"),
2279+ aliases: &["wqa", "xa"],
2273 doc: "Writes changes from all views to disk and close all views.",
2280 doc: "Writes changes from all views to disk and close all views.",
2274 fun: write_all_quit,
2281 fun: write_all_quit,
2275 completer: None,
2282 completer: None,
2277 TypableCommand {
2284 TypableCommand {
2278 name: "write-quit-all!",
2285 name: "write-quit-all!",
2279− alias: Some("wqa!"),
2286+ aliases: &["wqa!", "xa!"],
2280 doc: "Writes changes from all views to disk and close all views forcefully (ignoring unsaved changes).",
2287 doc: "Writes changes from all views to disk and close all views forcefully (ignoring unsaved changes).",
2281 fun: force_write_all_quit,
2288 fun: force_write_all_quit,
2282 completer: None,
2289 completer: None,
2284 TypableCommand {
2291 TypableCommand {
2285 name: "quit-all",
2292 name: "quit-all",
2286− alias: Some("qa"),
2293+ aliases: &["qa"],
2287 doc: "Close all views.",
2294 doc: "Close all views.",
2288 fun: quit_all,
2295 fun: quit_all,
2289 completer: None,
2296 completer: None,
2291 TypableCommand {
2298 TypableCommand {
2292 name: "quit-all!",
2299 name: "quit-all!",
2293− alias: Some("qa!"),
2300+ aliases: &["qa!"],
2294 doc: "Close all views forcefully (ignoring unsaved changes).",
2301 doc: "Close all views forcefully (ignoring unsaved changes).",
2295 fun: force_quit_all,
2302 fun: force_quit_all,
2296 completer: None,
2303 completer: None,
2298 TypableCommand {
2305 TypableCommand {
2299 name: "theme",
2306 name: "theme",
2300− alias: None,
2307+ aliases: &[],
2301 doc: "Change the theme of current view. Requires theme name as argument (:theme <name>)",
2308 doc: "Change the theme of current view. Requires theme name as argument (:theme <name>)",
2302 fun: theme,
2309 fun: theme,
2303 completer: Some(completers::theme),
2310 completer: Some(completers::theme),
2305 TypableCommand {
2312 TypableCommand {
2306 name: "clipboard-yank",
2313 name: "clipboard-yank",
2307− alias: None,
2314+ aliases: &[],
2308 doc: "Yank main selection into system clipboard.",
2315 doc: "Yank main selection into system clipboard.",
2309 fun: yank_main_selection_to_clipboard,
2316 fun: yank_main_selection_to_clipboard,
2310 completer: None,
2317 completer: None,
2312 TypableCommand {
2319 TypableCommand {
2313 name: "clipboard-yank-join",
2320 name: "clipboard-yank-join",
2314− alias: None,
2321+ aliases: &[],
2315 doc: "Yank joined selections into system clipboard. A separator can be provided as first argument. Default value is newline.", // FIXME: current UI can't display long doc.
2322 doc: "Yank joined selections into system clipboard. A separator can be provided as first argument. Default value is newline.", // FIXME: current UI can't display long doc.
2316 fun: yank_joined_to_clipboard,
2323 fun: yank_joined_to_clipboard,
2317 completer: None,
2324 completer: None,
2319 TypableCommand {
2326 TypableCommand {
2320 name: "primary-clipboard-yank",
2327 name: "primary-clipboard-yank",
2321− alias: None,
2328+ aliases: &[],
2322 doc: "Yank main selection into system primary clipboard.",
2329 doc: "Yank main selection into system primary clipboard.",
2323 fun: yank_main_selection_to_primary_clipboard,
2330 fun: yank_main_selection_to_primary_clipboard,
2324 completer: None,
2331 completer: None,
2326 TypableCommand {
2333 TypableCommand {
2327 name: "primary-clipboard-yank-join",
2334 name: "primary-clipboard-yank-join",
2328− alias: None,
2335+ aliases: &[],
2329 doc: "Yank joined selections into system primary clipboard. A separator can be provided as first argument. Default value is newline.", // FIXME: current UI can't display long doc.
2336 doc: "Yank joined selections into system primary clipboard. A separator can be provided as first argument. Default value is newline.", // FIXME: current UI can't display long doc.
2330 fun: yank_joined_to_primary_clipboard,
2337 fun: yank_joined_to_primary_clipboard,
2331 completer: None,
2338 completer: None,
2333 TypableCommand {
2340 TypableCommand {
2334 name: "clipboard-paste-after",
2341 name: "clipboard-paste-after",
2335− alias: None,
2342+ aliases: &[],
2336 doc: "Paste system clipboard after selections.",
2343 doc: "Paste system clipboard after selections.",
2337 fun: paste_clipboard_after,
2344 fun: paste_clipboard_after,
2338 completer: None,
2345 completer: None,
2340 TypableCommand {
2347 TypableCommand {
2341 name: "clipboard-paste-before",
2348 name: "clipboard-paste-before",
2342− alias: None,
2349+ aliases: &[],
2343 doc: "Paste system clipboard before selections.",
2350 doc: "Paste system clipboard before selections.",
2344 fun: paste_clipboard_before,
2351 fun: paste_clipboard_before,
2345 completer: None,
2352 completer: None,
2347 TypableCommand {
2354 TypableCommand {
2348 name: "clipboard-paste-replace",
2355 name: "clipboard-paste-replace",
2349− alias: None,
2356+ aliases: &[],
2350 doc: "Replace selections with content of system clipboard.",
2357 doc: "Replace selections with content of system clipboard.",
2351 fun: replace_selections_with_clipboard,
2358 fun: replace_selections_with_clipboard,
2352 completer: None,
2359 completer: None,
2354 TypableCommand {
2361 TypableCommand {
2355 name: "primary-clipboard-paste-after",
2362 name: "primary-clipboard-paste-after",
2356− alias: None,
2363+ aliases: &[],
2357 doc: "Paste primary clipboard after selections.",
2364 doc: "Paste primary clipboard after selections.",
2358 fun: paste_primary_clipboard_after,
2365 fun: paste_primary_clipboard_after,
2359 completer: None,
2366 completer: None,
2361 TypableCommand {
2368 TypableCommand {
2362 name: "primary-clipboard-paste-before",
2369 name: "primary-clipboard-paste-before",
2363− alias: None,
2370+ aliases: &[],
2364 doc: "Paste primary clipboard before selections.",
2371 doc: "Paste primary clipboard before selections.",
2365 fun: paste_primary_clipboard_before,
2372 fun: paste_primary_clipboard_before,
2366 completer: None,
2373 completer: None,
2368 TypableCommand {
2375 TypableCommand {
2369 name: "primary-clipboard-paste-replace",
2376 name: "primary-clipboard-paste-replace",
2370− alias: None,
2377+ aliases: &[],
2371 doc: "Replace selections with content of system primary clipboard.",
2378 doc: "Replace selections with content of system primary clipboard.",
2372 fun: replace_selections_with_primary_clipboard,
2379 fun: replace_selections_with_primary_clipboard,
2373 completer: None,
2380 completer: None,
2375 TypableCommand {
2382 TypableCommand {
2376 name: "show-clipboard-provider",
2383 name: "show-clipboard-provider",
2377− alias: None,
2384+ aliases: &[],
2378 doc: "Show clipboard provider name in status bar.",
2385 doc: "Show clipboard provider name in status bar.",
2379 fun: show_clipboard_provider,
2386 fun: show_clipboard_provider,
2380 completer: None,
2387 completer: None,
2382 TypableCommand {
2389 TypableCommand {
2383 name: "change-current-directory",
2390 name: "change-current-directory",
2384− alias: Some("cd"),
2391+ aliases: &["cd"],
2385 doc: "Change the current working directory (:cd <dir>).",
2392 doc: "Change the current working directory (:cd <dir>).",
2386 fun: change_current_directory,
2393 fun: change_current_directory,
2387 completer: Some(completers::directory),
2394 completer: Some(completers::directory),
2389 TypableCommand {
2396 TypableCommand {
2390 name: "show-directory",
2397 name: "show-directory",
2391− alias: Some("pwd"),
2398+ aliases: &["pwd"],
2392 doc: "Show the current working directory.",
2399 doc: "Show the current working directory.",
2393 fun: show_current_directory,
2400 fun: show_current_directory,
2394 completer: None,
2401 completer: None,
2396 TypableCommand {
2403 TypableCommand {
2397 name: "encoding",
2404 name: "encoding",
2398− alias: None,
2405+ aliases: &[],
2399 doc: "Set encoding based on `https://encoding.spec.whatwg.org`",
2406 doc: "Set encoding based on `https://encoding.spec.whatwg.org`",
2400 fun: set_encoding,
2407 fun: set_encoding,
2401 completer: None,
2408 completer: None,
2403 TypableCommand {
2410 TypableCommand {
2404 name: "reload",
2411 name: "reload",
2405− alias: None,
2412+ aliases: &[],
2406 doc: "Discard changes and reload from the source file.",
2413 doc: "Discard changes and reload from the source file.",
2407 fun: reload,
2414 fun: reload,
2408 completer: None,
2415 completer: None,
2410 TypableCommand {
2417 TypableCommand {
2411 name: "tree-sitter-scopes",
2418 name: "tree-sitter-scopes",
2412− alias: None,
2419+ aliases: &[],
2413 doc: "Display tree sitter scopes, primarily for theming and development.",
2420 doc: "Display tree sitter scopes, primarily for theming and development.",
2414 fun: tree_sitter_scopes,
2421 fun: tree_sitter_scopes,
2415 completer: None,
2422 completer: None,
@@ -2437,14 +2444,14 @@ mod cmd {
2438 TypableCommand {
2445 TypableCommand {
2439 name: "vsplit",
2446 name: "vsplit",
2440− alias: Some("vs"),
2447+ aliases: &["vs"],
2441 doc: "Open the file in a vertical split.",
2448 doc: "Open the file in a vertical split.",
2442 fun: vsplit,
2449 fun: vsplit,
2443 completer: Some(completers::filename),
2450 completer: Some(completers::filename),
2445 TypableCommand {
2452 TypableCommand {
2446 name: "hsplit",
2453 name: "hsplit",
2447− alias: Some("sp"),
2454+ aliases: &["hs", "sp"],
2448 doc: "Open the file in a horizontal split.",
2455 doc: "Open the file in a horizontal split.",
2449 fun: hsplit,
2456 fun: hsplit,
2450 completer: Some(completers::filename),
2457 completer: Some(completers::filename),
@@ -2452,16 +2459,13 @@ mod cmd {
2454 pub static COMMANDS: Lazy<HashMap<&'static str, &'static TypableCommand>> = Lazy::new(|| {
2461 pub static COMMANDS: Lazy<HashMap<&'static str, &'static TypableCommand>> = Lazy::new(|| {
2455− let mut map = HashMap::new();
2457− for cmd in TYPABLE_COMMAND_LIST {
2462+ TYPABLE_COMMAND_LIST
2458− map.insert(cmd.name, cmd);
2463+ .iter()
2459− if let Some(alias) = cmd.alias {
2464+ .flat_map(|cmd| {
2460− map.insert(alias, cmd);
2465+ std::iter::once((cmd.name, cmd))
2461− }
2466+ .chain(cmd.aliases.iter().map(move |&alias| (alias, cmd)))