fix(auto): make :MdRender auto a true toggle by swapping back to source on off#18
Merged
Merged
Conversation
`:MdRender auto` is `auto_toggle` in disguise, so calling it twice should return to the pre-toggle state. Previously `auto_off` only tore down the autocmd / keymaps / b: marker but left the render buffer on screen, so two `:MdRender auto` invocations ended up with auto OFF plus render still displayed — surprising for a toggle. Make `auto_off` also call `MdPreview.toggle()` when the current window is showing this buffer's render view. `auto_toggle` inherits the fix without further change. Update :help and tests accordingly.
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.
Summary
:MdRender auto(=auto_toggle) now returns to the pre-toggle state when called twice.MdPreview.auto_offswaps the current window back to source when it's showing this buffer's render view, in addition to clearingb:md_render_auto/ autocmds / Insert-entry keymaps.:help :MdRender-autoand:help MdPreview.auto_off()updated to match.Why
The previous
auto_offwas deliberately documented as "leaves the displayed mode untouched". That made:MdRender auto(toggle) asymmetric: source → render on the first call, but render stays render on the second call (only the autocmd is gone). Users reasonably expected a toggle to be reversible. Since auto mode is still marked[EXPERIMENTAL], tightening the contract to be symmetric is preferable to keeping the surprise.auto_toggleitself is unchanged; it inherits the fix fromauto_off.Test plan
make test— all 525 tests pass (toggle_test grew from 147 → 149).auto_offswaps render back to source (Test 18, rewritten).auto_togglecalls return to the original(source, auto-off)state (Test 18b).auto_offis a no-op for display when the current window is already showing source (Test 18c).🤖 Generated with Claude Code