From d1a323b4ac8972d523723c6b1a25ed8d25e8d3d6 Mon Sep 17 00:00:00 2001 From: hagz0r <48390403+hagz0r@users.noreply.github.com> Date: Mon, 9 Mar 2026 23:57:43 -0700 Subject: [PATCH] Fix parsing of filenames like main (1).log (#50770) ## Summary Fixes Windows file-open parsing for names like `main (1).log`. `PathWithPosition::parse_str` could treat `(1)` in a normal filename as a position suffix and drop the extension/path tail. The regex is now anchored so parenthesized row/column parsing only applies at the end of the filename (with optional trailing `:` and optional range suffix). ## Testing - `cargo test -p util path_with_position_parse_` Closes #50597 Release Notes: - Fixed opening files with names like `main (1).log` on Windows. --- crates/util/src/paths.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/crates/util/src/paths.rs b/crates/util/src/paths.rs index 39b4064a1bd9d3c4c240abf9665b17151066e9ef..3ff07c67a8d2def75e4e7f756c4a466ea2b68ed0 100644 --- a/crates/util/src/paths.rs +++ b/crates/util/src/paths.rs @@ -601,6 +601,7 @@ const ROW_COL_CAPTURE_REGEX: &str = r"(?xs) | \((\d+)\)() # filename(row) ) + \:*$ | (.+?)(?: \:+(\d+)\:(\d+)\:*$ # filename:row:column @@ -2097,6 +2098,15 @@ mod tests { column: Some(9), } ); + + assert_eq!( + PathWithPosition::parse_str("main (1).log"), + PathWithPosition { + path: PathBuf::from("main (1).log"), + row: None, + column: None + } + ); } #[perf] @@ -2175,6 +2185,15 @@ mod tests { column: None } ); + + assert_eq!( + PathWithPosition::parse_str("C:\\Users\\someone\\main (1).log"), + PathWithPosition { + path: PathBuf::from("C:\\Users\\someone\\main (1).log"), + row: None, + column: None + } + ); } #[perf]