Allow trailing newline to have fake position#18298
Merged
Merged
Conversation
ghost
reviewed
Sep 7, 2017
| if (res === debugText.length) { | ||
| return res; // Allow single character overflow for trailing newline | ||
| } | ||
| Debug.assert(res < debugText.length); |
There was a problem hiding this comment.
Couldn't you just use <= for the same effect? Currently this says: If res is len, return res, else assert that res < len and return res anyway.
Member
Author
There was a problem hiding this comment.
Yes; this just made it more explicit and less like an unintentional off-by-one error.
mhegazy
reviewed
Sep 7, 2017
| @@ -0,0 +1,12 @@ | |||
|
|
|||
| [100;30m2[0m | |||
mhegazy
approved these changes
Sep 7, 2017
Contributor
|
Will there be another 2.5 bugfix release? This one is getting in my way of open-sourcing another part of the bazel typescript rules. |
Contributor
|
We have no plans for a 2.5 release at the moment. is this a blocking issue for you? can you move to 2.6? |
Contributor
|
No problem. I worked around it by swapping out
formatDiagnosticsWithColorAndContext for formatDiagnostics in our bazel
implementation, for now.
…On Mon, Nov 6, 2017 at 1:49 PM Mohamed Hegazy ***@***.***> wrote:
We have no plans for a 2.5 release at the moment. is this a blocking issue
for you? can you move to 2.6?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#18298 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAC5I-UoibgS5cW9Q-4YFgxTzCoha_hiks5sz372gaJpZM4PPKU->
.
|
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
In #17121, an assertion was added to catch when we calculated a position outside a file's bounds; however the
prettydiagnostic printer relies on the fact that for a trailing newline we calculate a position one after the actual bounds of the file as the position for the first (nonexistant) character on that last line. An alternative was to adjustcomputeLineStartsto not include trailing newlines in the list of things calculated, then also adjust the baseline code to not consider trailing newlines as lines for writing errors on, then updating all the baselines; but that seemed a little less elegant than just allowing the one-character overflow; seeing as the calculated position always works as intended withsubstring.Also modifies the test harness a little bit to allow it to baseline
pretty-formatted diagnostics. They don't look terribly pretty in the baseline since they have ANSI escapes, but so be it.Fixes #18216