Repository navigation
zn v0.15.0: undo cannot wipe a note, autosave can be off, gd follows links like the desktop - #32
Merged
Merged
Conversation
…nks without .md Undo: a note opened by a key press starts as an empty editor, and its text arrived as an undoable change. `u` went back to empty and autosave wrote that over the file. The first successful read now replaces the placeholder outside the history (Editor.LoadText), so undo stops at the note as opened. A reload from disk stays undoable. A note that started empty can still undo to empty. If undo or redo leaves a buffer blank while its file has text, autosave, closing a tab and quitting no longer write it. `:w`, `Ctrl+S` and `:wq` still can, and deleting the text by hand is an edit that saves as ever. Autosave: `[terminal] autosave = false` is new, also through `zn config set` and `:settings`. With it off a note is written only when saved by name. `:q`, `:qa`, `Ctrl+C`, closing the last tab showing a note and switching vault refuse over unsaved edits, `:q!` and `:qa!` discard them, and any other exit leaves a recovery copy. Commands that act on the file itself still save first. gd: a Markdown link without `.md` was refused as "Not a note". The new vault.ResolveNoteHref ports the desktop's resolveInternalNoteHref: relative to the current note, tolerant of a missing extension and percent-encoding, then a wikilink lookup. A relative path now beats the same path from the vault root, which matches the desktop and differs from the old order. Tests: each behavior above, checked to fail with its fix reverted.
Markdown links with spaces in the destination are recognized, with or without angle brackets, and titles are dropped from the target. A dead link offers to create the note where it points, so the link resolves once the note exists. Hrefs that name a file or leave the vault still report "Not a note". A #heading or ^block anchor now lands on its target, on Markdown links and wikilinks alike, in the editor and in reading mode. Same-note anchors jump instead of offering a note with an empty name. Bare domains such as google.com open in the browser.
Fix(tui): gd follows links the way the desktop does
The README still warned that the desktop app drops [terminal] when it saves config.toml. Desktop 2.81.0 stopped doing that, and autosave = false, new in this release, is one of the settings people would lose by believing otherwise.
1 task
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.
Three fixes from a user report about
zn tui. The first one lost data.Undo could wipe a note
A note opened by a key press starts as an empty editor, and its text arrived as an undoable change. Pressing
uright after opening went back to empty, and autosave then wrote that over the file.Editor.LoadText), so undo stops at the note as opened. This also holds when the first read failed and a later one worked.:w,Ctrl+Sand:wqstill can, andggdGis an edit that saves as ever.Autosave can be turned off
There was no such setting, so every key was ignored.
[terminal] autosave = falseis new, and also works throughzn config set terminal.autosave falseand:settings. The default stays on.:w,Ctrl+S,:wq,:wa,:wqa:q,:qa,Ctrl+C, closing the last tab showing the note, switching vault:q!,:qa!$EDITORgdon a link with no.md[[2020-03-31](./Daily/2020-03-31)]gave "Not a note". The newvault.ResolveNoteHrefports the desktop'sresolveInternalNoteHref: relative to the current note, tolerant of a missing extension and percent-encoding, followed by a wikilink lookup.Behavior change to check in review: a relative path now beats the same path from the vault root. That matches the desktop and differs from the old TUI order.
Testing
go test ./...passes on macOS. New tests cover each behavior, and each fix's tests were checked to fail with that fix reverted.To try it:
u:Already at oldest change, and the file is intact.gg,jj,gd: the March 31 note opens.[terminal]andautosave = falseto$T/config/config.toml, relaunch and edit a note: the text is not on disk until:w, and:qrefuses.Not in this PR
[terminal], but desktop v2.81.0 and later keep it. On older desktops,autosave = falseis lost when the app rewritesconfig.toml.gdgaps with the desktop ([a](<./My Note>), offering to create a dead link's note, jumping to#heading) are being handled separately.