Fix parsing of filenames like main (1).log (#50770)

hagz0r created

## 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.

Change summary

crates/util/src/paths.rs | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)

Detailed changes

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]