Skip to content

edit_prediction: Fix special token check matching ======= inside comments#52510

Merged
osyvokon merged 4 commits intozed-industries:mainfrom
Shiven0504:fix/edit-prediction-special-token-false-positive
Mar 31, 2026
Merged

edit_prediction: Fix special token check matching ======= inside comments#52510
osyvokon merged 4 commits intozed-industries:mainfrom
Shiven0504:fix/edit-prediction-special-token-false-positive

Conversation

@Shiven0504
Copy link
Copy Markdown
Contributor

Closes #52489

The special token check in prompt_input_contains_special_tokens used String::contains() to look for =======\n in the buffer. This meant any line containing ======= (like // ======= section separators) would cause edit predictions to bail out entirely.

Fixed by only matching when the token appears at the start of a line, since the git merge markers are always placed at line boundaries in the prompt.

Added tests for both the helper function and a regression test for the reported issue.

…mments

The check used `contains()` which would match `=======\n` anywhere in
the buffer, including inside comments like `// =======`. Now it only
matches when the token is at the start of a line.

Fixes zed-industries#52489
@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Mar 26, 2026
@zed-community-bot zed-community-bot bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Mar 26, 2026
@zed-codeowner-coordinator zed-codeowner-coordinator bot requested review from a team, bennetbo and probably-neb and removed request for a team March 26, 2026 16:04
@osyvokon osyvokon assigned osyvokon and unassigned probably-neb Mar 30, 2026
special tokens ending with \n (like '=======\n') now match only when they occupy an entire line, preventing false positives in comments with separator characters
…r line 229

Removed the text_contains_line_start_token function and its associated tests to simplify the codebase
@Shiven0504
Copy link
Copy Markdown
Contributor Author

Removed the unused code as well as the test near the end👍

@zed-industries-bot
Copy link
Copy Markdown
Contributor

zed-industries-bot commented Mar 31, 2026

Warnings
⚠️

This PR is missing release notes.

Please add a "Release Notes" section that describes the change:

Release Notes:

- Added/Fixed/Improved ...

If your change is not user-facing, you can use "N/A" for the entry:

Release Notes:

- N/A

Generated by 🚫 dangerJS against b83edc0

@osyvokon osyvokon merged commit 56104fb into zed-industries:main Mar 31, 2026
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Edit Predictions do not work if .rs file contains sequence "// ======="

4 participants