Don't strip trailing newlines from files on save#92
Conversation
WalkthroughPreserve existing extra trailing newlines while ensuring at least one newline when parsing and rebuilding markdown; update save flow to only clear dirty flags if persisted content matches current editor state and expose Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Unexpected Cursor jump is more noticeable after write with this change. Notes from Claude which were initially incorrect... And after a bit of "read the fucking codebase and stop lying to me mate"... We should address this as part of this PR. |
…file as clean if content hasn't changed during save
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@src/hooks/editor/useEditorActions.ts`:
- Around line 95-100: The race-check clears dirty flags based only on
editorContent which can drop unsaved frontmatter edits; update the save
completion logic in useEditorActions (where useEditorStore.getState() is used)
to compare both current editorContent and current editorFrontmatter to the saved
editorContent and editorFrontmatter (or at minimum include frontmatter in the
equality check), and when setting useEditorStore.setState preserve any existing
isFrontmatterDirty by OR-ing the previous state's isFrontmatterDirty (i.e., only
clear isFrontmatterDirty if both content and frontmatter match the saved values)
so in-useEditorStore, use the current state values to determine final isDirty
and isFrontmatterDirty rather than blindly clearing them.
…ent jumping, especially during auto-save.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@test/dummy-astro-project/src/content/notes/copyedit-test.md`:
- Line 10: Replace the corrupted markdown header string "thh# Copyedit Mode
Testing" with a valid heading by removing the stray "thh" so it reads "#
Copyedit Mode Testing" (or adjust to the intended heading level like "##" if
needed); locate the line containing "thh# Copyedit Mode Testing" in
test/dummy-astro-project/src/content/notes/copyedit-test.md and update it
accordingly, or leave as-is if the "thh" prefix was intentionally included for
testing.
… and frontmatter for unsaved edits to improve state management during saves.
Closes #91
Summary by CodeRabbit
Bug Fixes
Enhancements
Tests
✏️ Tip: You can customize this high-level summary in your review settings.