Title: id(web): every .txt open→save drops the final newline (and rewrites CRLF to LF) — Plain mode is not byte-faithful unlike Raw · Issue #1307 · developing-today/code · GitHub
Open Graph Title: id(web): every .txt open→save drops the final newline (and rewrites CRLF to LF) — Plain mode is not byte-faithful unlike Raw · Issue #1307 · developing-today/code
X Title: id(web): every .txt open→save drops the final newline (and rewrites CRLF to LF) — Plain mode is not byte-faithful unlike Raw · Issue #1307 · developing-today/code
Description: id(web): every .txt open→save drops the final newline (and rewrites CRLF to LF) — Plain mode is not byte-faithful unlike Raw Summary Opening a plain-text (.txt) file in id and saving it — even with no edits — rewrites the file: the final...
Open Graph Description: id(web): every .txt open→save drops the final newline (and rewrites CRLF to LF) — Plain mode is not byte-faithful unlike Raw Summary Opening a plain-text (.txt) file in id and saving it — even with...
X Description: id(web): every .txt open→save drops the final newline (and rewrites CRLF to LF) — Plain mode is not byte-faithful unlike Raw Summary Opening a plain-text (.txt) file in id and saving it — even with...
Opengraph URL: https://github.com/developing-today/code/issues/1307
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"id(web): every .txt open→save drops the final newline (and rewrites CRLF to LF) — Plain mode is not byte-faithful unlike Raw","articleBody":"# id(web): every .txt open→save drops the final newline (and rewrites CRLF to LF) — Plain mode is not byte-faithful unlike Raw\n\n## Summary\n\nOpening a plain-text (`.txt`) file in id and saving it — even with no\nedits — rewrites the file: the final newline is always removed, and\nCRLF line endings are converted to LF. Raw mode round-trips\nbyte-exactly; Plain mode does not.\n\n## Evidence\n\n- Load: `pkgs/id/src/web/markdown.rs:1825` `plain_text_to_prosemirror`\n splits with `str::lines()`, which yields no element for a single\n trailing newline and strips the `\\r` of CRLF endings.\n- Save: `pkgs/id/src/web/routes.rs:2009` `extract_plain_text` joins\n paragraphs with `\"\\n\"` and appends nothing at the end — so the\n trailing newline the load discarded can never come back.\n- Verified this run on origin/main 90f7ea00 with a probe crate running\n the real load function plus the verbatim save function (log:\n `hidden_files/probe-2026-10-26-2352/out3.log`):\n - `\"alpha\\nbeta\\n\"` → `\"alpha\\nbeta\"` (final newline lost)\n - `\"alpha\\n\"` → `\"alpha\"`; `\"\\n\"` → `\"\"`; `\"alpha\\n\\n\"` → `\"alpha\\n\"`\n - `\"alpha\\r\\nbeta\\r\\n\"` → `\"alpha\\nbeta\"` (CRLF rewritten to LF)\n - Controls that round-trip exactly: `\"alpha\\nbeta\"` (no trailing\n newline) and `\"\"`.\n- Contrast: Raw mode (`raw_text_to_prosemirror` /\n `extract_raw_text`) keeps the whole file in one code block and\n round-trips byte-exactly, including the trailing newline.\n\n## Why it matters\n\nEvery POSIX text file ends in a newline; a no-op open→save in id\nproduces a spurious diff (`\\ No newline at end of file`), breaks\ntools that require a terminating newline, and silently converts\nCRLF files (common for notes shared with Windows editors) to LF.\nFidelity loss in the mode whose entire job is plain bytes.\n\n## Acceptance criteria\n\n- A documented, tested policy makes no-edit open→save of a `.txt`\n file byte-stable for the common shapes: trailing newline present\n or absent, and CRLF endings (either preserved, or — if LF\n normalization is the deliberate choice — called out in the mode's\n docs and pinned by a test, not accidental).\n- Regression tests cover at least: `\"a\\nb\\n\"`, `\"a\\nb\"`, `\"a\\n\"`,\n `\"\"`, and a CRLF sample, through the real load→save pair.\n- Markdown and Raw save/load behavior unchanged.\n\n## Notes\n\nThe information loss happens at load (`lines()` cannot distinguish\n`\"a\"` from `\"a\\n\"`), so a fix likely needs the load side to carry the\ntrailing-newline fact (e.g. a trailing empty paragraph, mirroring how\n`\"a\\n\\n\"` already loads) or the save side to adopt an\nalways-terminate policy — triage should pick and pin one.\n","author":{"url":"https://github.com/dezren39","@type":"Person","name":"dezren39"},"datePublished":"2026-10-27T05:34:14Z","url":"https://github.com/developing-today/code/issues/1307"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:da28cbc7-49c5-2ace-21ca-3d0bef842673 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 94FA:5F360:91C132:BCB008:6B062F95 |
| html-safe-nonce | e9e5216676c8f18ceef58b0f8f64f3ce6ed7d85dc1aa5ef815067b0987af74ea |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5NEZBOjVGMzYwOjkxQzEzMjpCQ0IwMDg6NkIwNjJGOTUiLCJ2aXNpdG9yX2lkIjoiNzcwNzc3MjA5MjQzMTA4NTQ2MSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 85052c4195fbc4e5e327145f59d64e7fabaec1aca74c6c57686543ce0fd74a81 |
| hovercard-subject-tag | issue:6053541772 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/developing-today/code/1307/issue_layout |
| twitter:image | https://opengraph.githubassets.com/3c7f90cd9900ca962a7797304b4260f2eb415e5d6be601e239637c15c6ef064e/developing-today/code/issues/1307 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/3c7f90cd9900ca962a7797304b4260f2eb415e5d6be601e239637c15c6ef064e/developing-today/code/issues/1307 |
| og:image:alt | id(web): every .txt open→save drops the final newline (and rewrites CRLF to LF) — Plain mode is not byte-faithful unlike Raw Summary Opening a plain-text (.txt) file in id and saving it — even with... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | dezren39 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7f961de5dd5c5d4aca24d33f8b3ffb3fb8b2ef53d0a4f32f01f0a790e512f6d3 |
| turbo-cache-control | no-preview |
| go-import | github.com/developing-today/code git https://github.com/developing-today/code.git |
| octolytics-dimension-user_id | 26439447 |
| octolytics-dimension-user_login | developing-today |
| octolytics-dimension-repository_id | 627308783 |
| octolytics-dimension-repository_nwo | developing-today/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 627308783 |
| octolytics-dimension-repository_network_root_nwo | developing-today/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 494ea0bb1e0feef734a83e2628697647755e8864 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width