From 7a7a4317b22140535c5d62ce90bd83b55e91d915 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 1 May 2026 12:44:43 +0000 Subject: [PATCH 1/2] Bump fancy-regex to 0.18.0 and enable CRLF handling Agent-Logs-Url: https://github.com/forkeith/zed/sessions/368f2b32-2b37-4960-85e6-2f7aeb5003bb Co-authored-by: keith-hall <11882719+keith-hall@users.noreply.github.com> --- Cargo.lock | 10 +++++----- Cargo.toml | 2 +- crates/project/src/search.rs | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 79e76d76f4ec3b..32352af8eb6fde 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6161,9 +6161,9 @@ dependencies = [ [[package]] name = "fancy-regex" -version = "0.17.0" +version = "0.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72cf461f865c862bb7dc573f643dd6a2b6842f7c30b07882b56bd148cc2761b8" +checksum = "e1e1dacd0d2082dfcf1351c4bdd566bbe89a2b263235a2b50058f1e130a47277" dependencies = [ "bit-set 0.8.0", "regex-automata", @@ -13427,7 +13427,7 @@ dependencies = [ "dap", "encoding_rs", "extension", - "fancy-regex 0.17.0", + "fancy-regex 0.18.0", "fs", "futures 0.3.32", "fuzzy", @@ -14490,9 +14490,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5276caf25ac86c8d810222b3dbb938e512c55c6831a10f3e6ed1c93b84041f1c" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" dependencies = [ "aho-corasick", "memchr", diff --git a/Cargo.toml b/Cargo.toml index a8c68c01ed6e7e..1c3234969fc04e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -577,7 +577,7 @@ emojis = "0.6.1" env_logger = "0.11" encoding_rs = "0.8" exec = "0.3.1" -fancy-regex = "0.17.0" +fancy-regex = "0.18.0" fork = "0.4.0" futures = "0.3.32" futures-concurrency = "7.7.1" diff --git a/crates/project/src/search.rs b/crates/project/src/search.rs index 83b4c585f1454e..293090730c6edf 100644 --- a/crates/project/src/search.rs +++ b/crates/project/src/search.rs @@ -243,6 +243,7 @@ impl SearchQuery { let regex = RegexBuilder::new(&pattern) .case_insensitive(!case_sensitive) + .crlf(true) .build()?; Ok(Self::Regex { regex, From 358a6239bf0f3bb4388a5424fff070843cce093f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 1 May 2026 14:13:30 +0000 Subject: [PATCH 2/2] project: Add CRLF multiline regex search integration test Agent-Logs-Url: https://github.com/forkeith/zed/sessions/9dccafe2-b436-48c2-893b-760fb1c97827 Co-authored-by: keith-hall <11882719+keith-hall@users.noreply.github.com> --- crates/project/tests/integration/search.rs | 33 +++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/crates/project/tests/integration/search.rs b/crates/project/tests/integration/search.rs index 79266405084d29..52f1587292f027 100644 --- a/crates/project/tests/integration/search.rs +++ b/crates/project/tests/integration/search.rs @@ -1,3 +1,4 @@ +use language::Buffer; use project::search::SearchQuery; use text::Rope; use util::{ @@ -130,6 +131,37 @@ fn test_case_sensitive_pattern_items() { ); } +#[gpui::test] +async fn test_multiline_regex_crlf(cx: &mut gpui::TestAppContext) { + // Verify that `$` line-end anchors work correctly on CRLF content. + // With .crlf(true) on the RegexBuilder, `$` in multiline mode matches + // before \r\n (not just before \n), so a pattern like `^hello$\r?\n` + // correctly matches "hello\r\n" in CRLF files. Without .crlf(true), + // `$` would only anchor before a bare \n, so the `\r` before the newline + // would prevent the anchor from firing and the pattern would never match. + let search_query = SearchQuery::regex( + "^hello$\r?\n", + false, + false, + false, + false, + Default::default(), + Default::default(), + false, + None, + ) + .expect("Should be able to create a regex SearchQuery"); + + let text = Rope::from("hello\r\nworld\r\nhello\r\nworld"); + let snapshot = cx + .update(|app| Buffer::build_snapshot(text, None, None, None, app)) + .await; + + let results = search_query.search(&snapshot, None).await; + // Each "hello\r\n" is 7 bytes; matches should cover those byte ranges. + assert_eq!(results, vec![0..7, 14..21]); +} + #[gpui::test] async fn test_multiline_regex(cx: &mut gpui::TestAppContext) { let search_query = SearchQuery::regex( @@ -145,7 +177,6 @@ async fn test_multiline_regex(cx: &mut gpui::TestAppContext) { ) .expect("Should be able to create a regex SearchQuery"); - use language::Buffer; let text = Rope::from("hello\nworld\nhello\nworld"); let snapshot = cx .update(|app| Buffer::build_snapshot(text, None, None, None, app))