Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

file_finder: Fix panic when file name contains new line (#26791)

Smit Barmaseae017c3f96ff
diff --git a/crates/util/src/paths.rs b/crates/util/src/paths.rs
index 1852f4f44cb..ecaa0d9bc2f 100644
--- a/crates/util/src/paths.rs
+++ b/crates/util/src/paths.rs
@@ -169,7 +169,7 @@ impl<T: AsRef<Path>> From<T> for SanitizedPath {
/// A delimiter to use in `path_query:row_number:column_number` strings parsing.
pub const FILE_ROW_COLUMN_DELIMITER: char = ':';
-const ROW_COL_CAPTURE_REGEX: &str = r"(?x)
+const ROW_COL_CAPTURE_REGEX: &str = r"(?xs)
([^\(]+)(?:
\((\d+)[,:](\d+)\) # filename(row,column), filename(row:column)
|
@@ -624,6 +624,24 @@ mod tests {
column: None
}
);
+
+ assert_eq!(
+ PathWithPosition::parse_str("ab\ncd"),
+ PathWithPosition {
+ path: PathBuf::from("ab\ncd"),
+ row: None,
+ column: None
+ }
+ );
+
+ assert_eq!(
+ PathWithPosition::parse_str("👋\nab"),
+ PathWithPosition {
+ path: PathBuf::from("👋\nab"),
+ row: None,
+ column: None
+ }
+ );
}
#[test]