fix: a trailing newline adds a phantom line number - #80
Open
lvolland wants to merge 1 commit into
Open
Conversation
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.
a code block whose source ends with a newline gets one line number too many.
today the gutter draws 2 numbers while the code column draws 1 line, so the last number sits next to nothing. expected is 1.
the count comes from
src.split('\n').length, which counts the empty segment after the final\n. that segment gets no line box underwhite-space: pre, so it should get no number. the fix drops one trailing newline before counting, inline in the same expression, no new variable:src/index.jsgoes 6190 -> 6209 bytes (+19).notes
\nchange. everything else is byte for byte identical,hideLineNumbersandmultiline: falseincluded.\r\nis covered:'a\r\nb\r\n'gives 2. i checked the counts against the rendered height in chrome, not just the string.'a\n\n'still gives 2.dist/is untouched, so the published bundle keeps the bug until minify-bot regenerates it.package.jsononly hasbuild, and the fixtures inexamples/languages/drivetokenize, nothighlightText, so there was nowhere to hang it without inventing a suite. happy to add one if you want :)