From af96b9ba2143df1cd7f7a4a0dff8302bbf17fd9a Mon Sep 17 00:00:00 2001 From: mo8it Date: Fri, 10 May 2024 18:48:28 +0200 Subject: [PATCH] Open file directly if not a glob --- helix-term/src/commands/typed.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/helix-term/src/commands/typed.rs b/helix-term/src/commands/typed.rs index 8e2d98267..64d179a52 100644 --- a/helix-term/src/commands/typed.rs +++ b/helix-term/src/commands/typed.rs @@ -156,7 +156,14 @@ fn open(cx: &mut compositor::Context, args: &[Cow], event: PromptEvent) -> continue; } - let glob = GlobBuilder::new(path.to_str().context("invalid unicode")?) + let path_str = path.to_str().context("invalid unicode")?; + if !path_str.as_bytes().iter().any(|c| b"*?{}[]".contains(c)) { + // Not a glob, open the file to avoid unneeded walking of huge directories + open_file(cx, &path, pos)?; + continue; + } + + let glob = GlobBuilder::new(path_str) .literal_separator(true) .empty_alternates(true) .build()