fix: a sheet name that begins with digits is lexed as a number and a name - #62
Open
gthb wants to merge 2 commits into
Open
fix: a sheet name that begins with digits is lexed as a number and a name#62gthb wants to merge 2 commits into
gthb wants to merge 2 commits into
Conversation
2020plan!A1 lexed as the number 2020 followed by plan!A1, so a sheet whose name begins with digits was not read as a prefix at all. The number lexer already declines when a "!" or ":" follows the digits directly, which is what makes 1!A1 and 1:5!A1 work; it did not look past the name characters between them. Digits that run on into name characters and then reach a "!" or ":" are now left to the name and prefix lexers. A number followed by a name that is not a prefix is unaffected, so 2020plan on its own is still the number 2020 and the name plan.
lexContextUnquoted already tested the set of characters an unquoted sheet name may contain, inline. The number lexer's new check transcribed that set into its own isNameChar. Extract the test into isUnquotedSheetNameChar in lexContext.ts and use it from both, so the set is defined once. The name says sheet name rather than context because the test only ever applies to that part of a prefix: the bracketed workbook name is exempt from it, and a path cannot appear unquoted.
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.
2020plan!A1lexes as the number2020followed by the referenceplan!A1, so a sheet whose name begins with digits is not read as a prefix at all. Excel reads2020planas the sheet name and stores it quoted,'2020plan'!A1.parseA1Refalready reads one prefix; only the formula lexers disagreed. The number lexer declines when a!or:directly follows the digits, which is what makes1!A1and1:5!A1work, but did not look past the name characters between.lexNumbernow declines when the digits run on into sheet-name characters that end at a!or:, leaving the position to the name and prefix lexers.2020planon its own is still the number2020and the nameplan.