Skip to content

Check for leading newlines when determining if block indentation indicator is needed#404

Merged
puzrin merged 2 commits intonodeca:masterfrom
trevorr:issue-403
Mar 16, 2018
Merged

Check for leading newlines when determining if block indentation indicator is needed#404
puzrin merged 2 commits intonodeca:masterfrom
trevorr:issue-403

Conversation

@trevorr
Copy link
Copy Markdown
Contributor

@trevorr trevorr commented Mar 15, 2018

Fixes #403

Comment thread lib/js-yaml/dumper.js Outdated
}
// Edge case: block indentation indicator can only have one digit.
if (string[0] === ' ' && indentPerLevel > 9) {
if (needIndentIndicator(string) && indentPerLevel > 9) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking back, an optimization would be to short-circuit by first comparing indentPerLevel > 9, because it's almost always something like 2, 4, or 8. Likely not a big deal though.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. I'm happy to change it, or you can.

@puzrin puzrin merged commit bab69b5 into nodeca:master Mar 16, 2018
@puzrin
Copy link
Copy Markdown
Member

puzrin commented Mar 16, 2018

Thanks!

minj added a commit to minj/js-yaml that referenced this pull request Apr 28, 2018
* master: (58 commits)
  Check for leading newlines when determining if block indentation indicator is needed (nodeca#404)
  Add property based tests to assess load reverses dump (nodeca#398)
  3.11.0 released
  Browser files rebuild
  Dumper: fix negative integers in bin/octal/hex formats, close nodeca#399
  support es6 arrow functions, fixes nodeca#389 (nodeca#393)
  Fix typo in README.md (nodeca#373)
  3.10.0 released
  Browser files rebuild
  Add test for astrals dump
  Combine surrogate pairs into one escape sequence when encoding. (nodeca#369)
  Fix condenseFlow for objects (nodeca#371)
  correct spelling mistake (nodeca#367)
  More meaningful error for loader (nodeca#361)
  Fix typo and format code. (nodeca#365)
  3.9.1 released
  Browser files rebuild
  Ensure stack is present for custom errors (fixes nodeca#351) (nodeca#360)
  3.9.0 released
  Browser files rebuild
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants