{{ message }}
Repository navigation
fix: #2143 open missing CLI files as named buffers - #5758
Merged
Merged
Conversation
Contributor
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Critical save-conflict issues and two moderate path/line-ending issues remain unresolved.
2 open findings
What changed in this PR
Adds support for opening missing Markdown CLI paths as named buffers, creating files only on save.
Changes:
- Tracks pending creation through IPC, renderer state, buffering, and restoration.
- Adds save conflict handling and macOS window activation.
- Adds unit and Electron E2E coverage.
Review findings include two critical save/conflict issues and two moderate path/line-ending issues requiring resolution.
🧠 Review effort: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Closes #2143
Summary
Running
marktext foo.mdcurrently discards the path when the file does not exist. Open it as a named, empty buffer instead, on both initial startup and subsequent CLI invocations. Preserve the absolute target path so Save creates the file directly, including an empty file. Opening and closing an unmodified buffer does not create a file or prompt to save.Track pending creation separately from unsaved edits through IPC, buffered state, and session restoration. Register watchers and recent documents after the first successful save, and confirm replacement if another process creates the target before that save. Canceling a save keeps the window open. Existing file/directory handling, supported extensions, window preferences, and
--new-windowremain supported; the parent directory must exist.Activate the application on macOS when bringing an editor window forward, so CLI invocations restore and focus hidden or minimized windows.
Type of change
Test plan
--new-window, external-file conflict cancellation, and macOS application activation after hiding/minimizing.pnpm run test:unit— 99 files / 1103 tests passed.pnpm -C packages/desktop exec playwright test test/e2e/cli-missing-file-2143.spec.ts— passed.pnpm run typecheck— passed.pnpm run lint— passed, 0 errors (existing warnings).pnpm run build:unpack— passed..appand verified named CLI opening without an immediate disk write. Local packaging output and launcher are outside the checkout.Notes for reviewers
To reproduce: run
marktext foo.mdin an existing directory with nofoo.md; check that the buffer is named and the file is absent, then save and check the file is created. While the app remains running, runmarktext bar.md; verify the named buffer opens and the window comes forward. Closing an unmodifiedbar.mdbuffer should leave no file behind.No
--waitsupport is included.By submitting this pull request, I confirm that my contribution is made under the terms of the MIT license.