Repository navigation
fix(optimizer): insert_after a target that ends in a newline right after it - #408
Open
Muhammad Abdullah Butt (1AbdullahButt) wants to merge 1 commit into
Conversation
…ter it insert_after finds the end of the target's line by searching for the next newline from the end of the target. When the target already ends with "\n", that search found the end of the following line, so the content landed one line too late: under the next heading, or inside a protected region whose start marker follows directly. Insert at the end of the target when it already ends its line. Fixes microsoft#407 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #407
insert_afterfound the end of the target's line by searching for the next\nfrom the end of the target. When the target already ends with\n, that search found the end of the following line, so the content landed one line too late: under the next heading, or inside a protected region whose start marker follows directly.The fix inserts at the end of the target when the target already ends its line. Targets without a trailing newline behave as before.
Tests
tests/test_insert_after_newline_target.py: the issue's repro, a check that"## Rules\n"and"## Rules"now give the same result, and a check that the content stays outside a slow-update region that follows directly. All three fail onmainand pass here.tests/test_skill_aware_reflection.py,tests/test_types.pyand the other tests that apply edits still pass (Windows, Python 3.10). The only failures in that set are the pre-existing Windows ones intests/test_sleep_engine.py, which does not useskillopt/optimizer.Claude Code wrote this change.
🤖 Generated with Claude Code