Take the name of a file that is not there yet - #13
Conversation
Backend::open only reads: a path with nothing behind it fails the ReadOnly open, reports "Could not open", and returns before setFileUrl, so the document keeps no name at all. Opening a file that has yet to be written -- `omawrite new_document.md`, the way every editor is asked to start one -- therefore left Ctrl+S with nothing to save to, and the portal's Save As dialog asked for a name the writer had already given. Claim the URL for a blank document when the path is not there, and let the first save land on it. A path that exists but cannot be read is still an error, as it should be: this is only about the file that is not there yet. Fixes omacom-io#6 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TyQRJCyR76uk7XaNAB8jMC
Taking any absent path meant a name under a directory that is not there was accepted too, and the failure moved from the open to the first save: `omawrite ~/notes/2026/draft.md` with no `2026/` directory opened a document titled `draft.md`, and Ctrl+S then answered with `Could not save draft.md.` in the footer and no dialog, because the URL was valid enough to skip the Save As fallback that used to catch this. Same for a name in a directory the writer cannot write, and for a trailing-slash path, which is a directory name that `fileName()` reports as `Untitled.md`. Claim the name only where the file could actually be created. Everything else keeps master's answer: `Could not open`, and the first save still offers somewhere to put the text. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Reviewed against Pushed Two things I did not change, for the maintainer to decide:
Worth knowing before merge: #9 rewrites the same function. It routes every write of |
Fixes #6. The analysis and the shape of this fix are @Vyrnexis's, from the issue.
Backend::openonly reads. A path with nothing behind it fails theReadOnlyopen, reports "Could not open", and returns beforesetFileUrl, so the document ends up with no name at all — andBackend::savefalls back tosaveAsDialog(). Starting a file the way every editor is asked to start one,omawrite new_document.md, therefore met the portal's Save As dialog asking for a name that had already been given on the command line.opennow claims the URL for a blank document when the path is not there yet, so the first save lands where the writer said it should. A path that exists but cannot be read — a directory, a file without read permission — is still an error, and still leaves the document it could not replace alone.The status line says
New file new_document.md, and nothing is written until the writer saves.Test
startsANewFileFromAPathThatIsNotThereYetdrives the realMain.qmldocument:QSignalSpyonsaveDialogRequestedstays at 0);Could not open, keeping the previous document and its URL.The test fails on
master(fileUrlcomes back invalid) and passes with the fix. Full suite inbuild-tests: 13 passed, 0 failed.🤖 Generated with Claude Code
https://claude.ai/code/session_01TyQRJCyR76uk7XaNAB8jMC