Skip to content

fix(builtin): preserve trailing newline in fs.edit - #395

Merged
frostming merged 1 commit into
mainfrom
fix/fs-edit-trailing-newline
Nov 4, 2026
Merged

frostming merged 1 commit into
mainfrom
fix/fs-edit-trailing-newline

Conversation

@frostming

Copy link
Copy Markdown
Contributor

Problem

The built-in fs.edit rebuilds the file with "\n".join(text.splitlines()). splitlines() drops the final line terminator, so every edit strips the file's trailing newline, and linters then report it (e.g. ruff W292).

Fix

If the original text ends with a newline, add one back when writing. bub-acp-server's client-backed fs.edit already does this.

Added test_fs_edit_preserves_trailing_newline. It fails without the fix.

🤖 Generated with Claude Code

`splitlines()` drops the final line terminator, so every edit stripped
the file's trailing newline (e.g. ruff W292).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bub a13d652 Commit Preview URL

Branch Preview URL
Nov 04 2026, 01:09 AM

@frostming
frostming merged commit f983b37 into main Nov 4, 2026
7 checks passed
@frostming
frostming deleted the fix/fs-edit-trailing-newline branch November 4, 2026 01:21
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