Repository navigation
Keep the source spelling of floats copied into an editable document - #6123
Open
atharva-potdar wants to merge 1 commit into
Open
atharva-potdar wants to merge 1 commit into
atharva-potdar wants to merge 1 commit into
Conversation
An edit that copies a float from a view of another document stores the source token verbatim in the edit arena and marks the node as edited. dump(number_format::source) copied only tokens outside the edit arena, so the copied float was written in the shortest form while number_token() and the saved image kept the source token. load(doc.save()).dump(source) thus differed from doc.dump(source), although save() writes the current state. Copy an edited float token as well, except nan, inf and -inf, which remain null. Tokens written by set() or push_back() already contain the BasicJsonType::dump() form, so their output does not change. Add a regression test for a float copied from another document and update editing.md to state that a copied number keeps its spelling. An integer copied from another document is still rebuilt in canonical form, so -0 becomes 0. Fixes nlohmann#6113. Signed-off-by: atharva-potdar <atharvapotdar07@gmail.com>
This branch has not been deployed
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.
Fixes #6113.
An edit that copies a float from a view of another document stores the source token verbatim in the edit arena and marks the node as edited.
dump(number_format::source)copied only tokens outside the edit arena, so the copied float was written in the shortest form whilenumber_token()and the saved image kept the source token. Consequently,load(doc.save()).dump(source)differed fromdoc.dump(source), althoughsave()writes the current state.Copy an edited float token as well, except
nan,inf, and-inf, which remainnull. Tokens written byset()orpush_back()already contain theBasicJsonType::dump()form, so their output does not change. An integer copied from another document is still rebuilt in canonical form, so-0becomes0.Add a regression test for a float copied from another document and update
editing.mdto state that a copied number keeps its spelling.Fixes #6113).make amalgamate.