Skip to content

Fix for https://github.com/dart-lang/tools/issues/2481 - #2482

Open
slashblog wants to merge 2 commits into
dart-lang:mainfrom
slashblog:bug-fixes
Open

Fix for https://github.com/dart-lang/tools/issues/2481#2482
slashblog wants to merge 2 commits into
dart-lang:mainfrom
slashblog:bug-fixes

Conversation

@slashblog

Copy link
Copy Markdown
  • This change addresses the following issue I raised earlier. The original issue has more details (including the cause of the issue and steps to reproduce), but briefly adding an item to a list causes the following exception to be thrown: "Failed to produce valid YAML after modification.". This change fixes this issue.

  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

Many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.

Note: The Dart team is trialing Gemini Code Assist. Don't take its comments as final Dart team feedback. Use the suggestions if they're helpful; otherwise, wait for a human reviewer.

@slashblog
slashblog requested a review from a team as a code owner July 31, 2026 06:05
@google-cla

google-cla Bot commented Jul 31, 2026

Copy link
Copy Markdown

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the block list appending logic in yaml_edit to trim trailing whitespace when finding the next newline index. The reviewer identified a performance issue where creating a substring on every append operation leads to O(N) time and memory complexity, as well as a potential RangeError crash if the index becomes negative. An optimized O(1) auxiliary space solution was suggested to scan backwards instead.

Comment thread pkgs/yaml_edit/lib/src/list_mutations.dart Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant