fix(viewer): byte-faithful saves, poll/save races, clearer errors
- Keep CRLF (or CR) line endings and a UTF-8 BOM through the editor: textFormat.ts records the dominant separator and the BOM on load and restores both on save, so a save changes only the user's edits. - A clean document whose reload failed retries on the next poll. - A poll that overlaps a save, or was issued before one settled, is ignored instead of reading the pre-save hash as a change. - A conflict whose follow-up poll has no hash shows an error with a Reload button rather than an Overwrite that could only conflict again. - Match write.rs's exact read-only message; show the read-only reason as visible text; error banners are role="alert". - vite/client types move to src/vite-env.d.ts. - Tests: CRLF and BOM saves, reload retry, poll/save race, null-hash conflict, Save and close success and failure, and CodeEditor.setDoc keeping cursor and scroll. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -43,6 +43,10 @@ describe("reduceViewer", () => {
|
||||
expect(reloaded).toMatchObject({ disk: "same", diskHash: H3, baseHash: H1, justReloaded: true });
|
||||
expect(pollEffect(reloaded, poll(reloaded, H3))).toBe("none");
|
||||
});
|
||||
it("a clean doc still marked changed (its reload failed) retries on the next identical poll", () => {
|
||||
const changed = poll(loaded(), H2);
|
||||
expect(pollEffect(changed, poll(changed, H2))).toBe("reload");
|
||||
});
|
||||
it("a changed poll on a dirty doc shows the banner and never reloads", () => {
|
||||
const s = reduceViewer(loaded(), { type: "edited" });
|
||||
const after = poll(s, H2);
|
||||
|
||||
Reference in New Issue
Block a user