Skip to content

fix: Preserve trailing newlines instead of adding them unconditionally#29124

Closed
Genbox wants to merge 1 commit into
anomalyco:devfrom
Genbox:dev
Closed

fix: Preserve trailing newlines instead of adding them unconditionally#29124
Genbox wants to merge 1 commit into
anomalyco:devfrom
Genbox:dev

Conversation

@Genbox
Copy link
Copy Markdown

@Genbox Genbox commented May 24, 2026

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

When opencode makes a change to a file via apply_patch, it also adds a trailing newline. This unnecessary change causes issues and is not expected. This PR preserves when files contain a trailing newline and does not add new ones to files that are changed.

How did you verify your code works?

I've extended the appropriate unit tests to verify that no trailing newlines are added and that existing ones are preserved.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

@github-actions
Copy link
Copy Markdown
Contributor

Hey! Your PR title Preserve trailing newlines instead of adding them unconditionally doesn't follow conventional commit format.

Please update it to start with one of:

  • feat: or feat(scope): new feature
  • fix: or fix(scope): bug fix
  • docs: or docs(scope): documentation changes
  • chore: or chore(scope): maintenance tasks
  • refactor: or refactor(scope): code refactoring
  • test: or test(scope): adding or updating tests

Where scope is the package name (e.g., app, desktop, opencode).

See CONTRIBUTING.md for details.

@github-actions github-actions Bot added needs:title needs:compliance This means the issue will auto-close after 2 hours. labels May 24, 2026
@github-actions
Copy link
Copy Markdown
Contributor

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

Based on my search, I found a related PR that is worth noting:

Related PR:

The other results (PRs #26374, #28622, #28643) are about adding trailing newlines to help output, which is the opposite concern from what PR #29124 addresses.

These are not true duplicates, but #20217 represents related work in the area of preserving file formatting characteristics during modifications.

@Genbox Genbox changed the title Preserve trailing newlines instead of adding them unconditionally fix: Preserve trailing newlines instead of adding them unconditionally May 24, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Copy Markdown
Contributor

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions Bot removed the needs:compliance This means the issue will auto-close after 2 hours. label May 24, 2026
@github-actions github-actions Bot closed this May 24, 2026
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