Fix path parsing for goto syntax provided by Haskell language server (#33697)

abhimanyu maurya created

path parsing for multiline errors provided by haskell language server
where not working correctly

<img width="875" alt="image"
src="https://github.com/user-attachments/assets/967d2e03-e167-4055-9c8e-31531cca1471"
/>

while its being parsed correctly in vscode

<img width="934" alt="image"
src="https://github.com/user-attachments/assets/a881cf0e-f06e-4b44-8363-6295bcc825fd"
/>

Release Notes:

- Fixed path parsing paths in the format of the Haskell language server

Change summary

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

Detailed changes

crates/util/src/paths.rs 🔗

@@ -170,6 +170,12 @@ impl<T: AsRef<Path>> From<T> for SanitizedPath {
 pub const FILE_ROW_COLUMN_DELIMITER: char = ':';
 
 const ROW_COL_CAPTURE_REGEX: &str = r"(?xs)
+    ([^\(]+)\:(?:
+        \((\d+)[,:](\d+)\) # filename:(row,column), filename:(row:column)
+        |
+        \((\d+)\)()     # filename:(row)
+    )
+    |
     ([^\(]+)(?:
         \((\d+)[,:](\d+)\) # filename(row,column), filename(row:column)
         |
@@ -674,6 +680,15 @@ mod tests {
                 column: None
             }
         );
+
+        assert_eq!(
+            PathWithPosition::parse_str("Types.hs:(617,9)-(670,28):"),
+            PathWithPosition {
+                path: PathBuf::from("Types.hs"),
+                row: Some(617),
+                column: Some(9),
+            }
+        );
     }
 
     #[test]