Repository navigation
Keep Jupyter cell types and ask before replacing a .verso on save - #117
Merged
Merged
Conversation
Saving a notebook opened from an .ipynb writes a sibling .verso file unless the original format is kept, which is intended. Three things around it were not. verso serve --preserve-format did nothing when Save was pressed. The editor decided whether to redirect to .verso by asking only whether a serializer always keeps its own format, so the path was changed before the code that honours the option could see it. That decision now comes from the same rule that picks the serializer, so the two cannot disagree. The Jupyter reader ignored metadata.verso_type. The writer stores a Mermaid, HTML, or extension cell as a raw cell carrying its Verso type, and the reader turned it back into a raw cell, so a notebook that went out to .ipynb and back lost every cell Jupyter cannot represent. A raw cell with that marker now gets its type back; a plain raw cell stays raw. Converting on save replaced an existing .verso without asking, which is how a Jupyter copy made with verso convert could overwrite its own original. The browser editor and VS Code now ask before the conversion replaces a file that is already there, and point Jupyter users at the option or setting that keeps the original format. Saving to a .verso file directly, and later saves once the notebook has moved to its .verso file, do not ask. The command line is unchanged. The new strings are translated into every shipped language. Tests cover the preserve-format decision and the verso_type round trip, each failing on the previous code, and the editor flow was checked in a browser against the report's own notebook. Fixes #114. Signed-off-by: Torrey Betts <[email protected]>
2 tasks done
SummarySummary
CoverageVerso - 82.2%
Verso.Abstractions - 84.2%
Verso.Ado - 81.4%
Verso.Blazor - 30.7%
Verso.Blazor.Shared - 61.9%
Verso.Cli - 41.4%
Verso.DataFrame - 82.3%
Verso.FSharp - 81.8%
Verso.Host - 56%
Verso.Http - 74.7%
Verso.JavaScript - 52.7%
Verso.PowerShell - 64.7%
Verso.Python - 78.1%
Verso.Sample.Diagram - 80.1%
Verso.Sample.Dice - 82.2%
Verso.Sample.Slides - 58.8%
Verso.Sample.Sparkline - 67.3%
Verso.Testing - 79.7%
|
This patch hardens the save/replace flow: the replace dialog opens with Cancel focused, Escape closes it without editing the notebook, and keys while the prompt is open are ignored instead of acting on the live notebook. It also adds a real `verso serve` browser E2E suite covering the replace-confirmation behavior. In VS Code, a canceled conversion save now throws cancellation so the document is not incorrectly marked clean. Signed-off-by: Torrey Betts <[email protected]>
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.
Saving a notebook opened from an .ipynb writes a sibling .verso file unless the original format is kept, which is intended. Three things around it were not.
verso serve --preserve-format did nothing when Save was pressed. The editor decided whether to redirect to .verso by asking only whether a serializer always keeps its own format, so the path was changed before the code that honours the option could see it. That decision now comes from the same rule that picks the serializer, so the two cannot disagree.
The Jupyter reader ignored metadata.verso_type. The writer stores a Mermaid, HTML, or extension cell as a raw cell carrying its Verso type, and the reader turned it back into a raw cell, so a notebook that went out to .ipynb and back lost every cell Jupyter cannot represent. A raw cell with that marker now gets its type back; a plain raw cell stays raw.
Converting on save replaced an existing .verso without asking, which is how a Jupyter copy made with verso convert could overwrite its own original. The browser editor and VS Code now ask before the conversion replaces a file that is already there, and point Jupyter users at the option or setting that keeps the original format. Saving to a .verso file directly, and later saves once the notebook has moved to its .verso file, do not ask. The command line is unchanged.
The new strings are translated into every shipped language. Tests cover the preserve-format decision and the verso_type round trip, each failing on the previous code, and the editor flow was checked in a browser against the report's own notebook. Fixes #114.
The VS Code prompt typechecks but has not been exercised in a running VS Code yet.