This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
Fix insertion of newline characters to the end of lines #100
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.
This pull request fixes three things.
Grammar.tokenizeLine
(source for off-by-one error in Atom 1.18+ token matching behaving strangely atom#14982)Rule.getNextTags
was supplied with a line that contains newline character, although it expects one without (source for the other off-by-one error described in Showcase off-by-one error in language-html #99)If anyone asks, the newlines are appended so that it is possible to match them using patterns like
$\n,
as newlines are stripped whenGrammar.tokenizeLines
does splitting by\n
. Currently by defaultGrammar.tokenizeLine
is assumed to do the appending.The branch in
Rule.getNextTags
expects a line without a newline because this is used to generate the tokens for the final output. If it contained a newline, then also the output tokens based off it would contain a newline. I would prefer if tokenizer output contained newlines, which would make possible to tokenize newlines (and for instance give a different right side scope at the end of the line), however this would be a breaking change as Atom does not expect newlines in tokenizer output and the API in general would change.I believe this is the best fix we can have for now. I haven't tested this with Atom yet, because I couldn't figure out/have forgotten how to get these changes easily into a build.
Fixes #99
Fixes atom/atom#14982