Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(yaml): end comment in nested mapping #4918

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(yaml): end comment in nested mapping
  • Loading branch information
ikatyang committed Jul 31, 2018
commit 4186664cc89c2a5ba134e68f769ed1d9a897bdc1
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"unicode-regex": "1.0.1",
"unified": "6.1.6",
"yaml": "1.0.0-rc.7",
"yaml-unist-parser": "1.0.0-rc.2"
"yaml-unist-parser": "1.0.0-rc.3"
},
"devDependencies": {
"@babel/cli": "7.0.0-beta.49",
Expand Down
2 changes: 2 additions & 0 deletions src/language-yaml/printer-yaml.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,8 @@ function _print(node, parentNode, path, options, print) {
needsSpaceInFrontOfMappingValue(node) ? " " : "",
":",
hasLeadingComments(node.value.node) ||
(hasEndComments(node.value) &&
node.value.node.type !== "null") ||
(parentNode.type === "mapping" &&
hasTrailingComments(node.key.node) &&
isInlineNode(node.value.node)) ||
Expand Down
13 changes: 7 additions & 6 deletions tests/yaml_comment/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ f:
empty_content:
# hello world
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a: 123
a:
123
# impicitMappginValue

? b
Expand Down Expand Up @@ -79,17 +80,17 @@ A:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
parent:
one: 1
# two: 2
# two: 2

a:
b:
#b
#a
#a

A:
B:
#A
#A
? B
#A
#A

`;

Expand Down
2 changes: 1 addition & 1 deletion tests/yaml_root/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ omap:
- aardvark: African pig-like ant eater. Ugly.
- anteater: South-American ant eater. Two species.
- anaconda: South-American constrictor snake. Scaly.
# Etc.
# Etc.
# Flow style
Numbers: !!omap [one: 1, two: 2, three: 3]

Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6008,9 +6008,9 @@ yallist@^3.0.0, yallist@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.0.2.tgz#8452b4bb7e83c7c188d8041c1a837c773d6d8bb9"

[email protected].2:
version "1.0.0-rc.2"
resolved "https://registry.yarnpkg.com/yaml-unist-parser/-/yaml-unist-parser-1.0.0-rc.2.tgz#a9c3597fe8507d7b80c7c51fc1c1ae4773ccdd30"
[email protected].3:
version "1.0.0-rc.3"
resolved "https://registry.yarnpkg.com/yaml-unist-parser/-/yaml-unist-parser-1.0.0-rc.3.tgz#d7b396353da92c75bb471a9e65973ba967e0b4f6"
dependencies:
lines-and-columns "^1.1.6"
tslib "^1.9.1"
Expand Down