Skip to content

fix(builtin): preserve leading blank lines in fs.edit when start > 0 - #410

Open
KuljeetSinghXDA wants to merge 1 commit into
bubbuild:mainfrom
KuljeetSinghXDA:fix/fs-edit-leading-blank-line
Open

KuljeetSinghXDA wants to merge 1 commit into
bubbuild:mainfrom
KuljeetSinghXDA:fix/fs-edit-leading-blank-line

Conversation

@KuljeetSinghXDA

Copy link
Copy Markdown

Summary

Fixes fs.edit in src/bub/builtin/tools.py when start > 0 and the prefix lines are blank (for example start=1 on a file starting with an empty line "\ny = 2\n").

Previously, if prev: checked truthiness instead of start > 0, so an empty prev ("") caused the leading blank line to be silently dropped. Also rejects negative start values with ValueError instead of slicing from the end of the file.

Verification

  • uv run ruff check src/bub/builtin/tools.py tests/test_environment.py: passed
  • uv run mypy src: Success: no issues found in 77 source files
  • uv run pytest tests/test_environment.py -q: 12 passed

This branch has not been deployed

No deployments
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.

2 participants