Skip to content

Conversation

@shilangyu
Copy link

Here is the first out of six PRs aiming to bring look-behinds to rust-regex. See #1266 for more information, notably the implementation plan.

In this PR we focus on adding look-behind support to the regex-syntax crate. New additions are hidden behind a feature flag to not break compatibility with other crates.

Currently the CI fails on generation of docsrs. This is due to all features being enabled during generation which breaks regex-automata. This will be fixed in the second PR which works on regex-automata.

ConradIrwin added a commit to zed-industries/zed that referenced this pull request Dec 4, 2025
Fancy regex has a max backtracking limit which defaults to 1,000,000
backtracks. This avoids spinning the CPU forever in the case that a
match is taking a long time (though does mean that some matches may be
missed).

Unfortunately the verison we depended on causes an infinite loop when
the backtracking limit is hit
(fancy-regex/fancy-regex#137), so we got the
worse of both worlds: matches were missed *and* we spun the CPU forever.

Updating fixes this.

Excitingly, in the future, regex may gain support for lookarounds
(rust-lang/regex#1315), which will make
fancy-regex much less load bearing.

Closes #43821
ConradIrwin added a commit to zed-industries/zed that referenced this pull request Dec 4, 2025
Fancy regex has a max backtracking limit which defaults to 1,000,000
backtracks. This avoids spinning the CPU forever in the case that a
match is taking a long time (though does mean that some matches may be
missed).

Unfortunately the verison we depended on causes an infinite loop when
the backtracking limit is hit
(fancy-regex/fancy-regex#137), so we got the
worse of both worlds: matches were missed *and* we spun the CPU forever.

Updating fixes this.

Excitingly regex may gain support for lookarounds
(rust-lang/regex#1315), which will make
fancy-regex much less load bearing.

Closes #43821

Release Notes:

- Fix a bug where search regexes with look-around or backreferences
could hang
  the CPU. They will now abort after a certain number of match attempts.
AlpSha pushed a commit to AlpSha/zed that referenced this pull request Dec 5, 2025
Fancy regex has a max backtracking limit which defaults to 1,000,000
backtracks. This avoids spinning the CPU forever in the case that a
match is taking a long time (though does mean that some matches may be
missed).

Unfortunately the verison we depended on causes an infinite loop when
the backtracking limit is hit
(fancy-regex/fancy-regex#137), so we got the
worse of both worlds: matches were missed *and* we spun the CPU forever.

Updating fixes this.

Excitingly regex may gain support for lookarounds
(rust-lang/regex#1315), which will make
fancy-regex much less load bearing.

Closes zed-industries#43821

Release Notes:

- Fix a bug where search regexes with look-around or backreferences
could hang
  the CPU. They will now abort after a certain number of match attempts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant