Repository navigation
fix: range 'a':'b'!A1 is mistaken for sheet range a:b!A1 #66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
f154a05
fix: a quoted scope in an operand position does not parse
gthb f022b88
Pin that the corrected type parses
gthb a7e5d7f
Say that the parse test pins fx's reading, not Excel's
gthb 92fc49d
Excel reads these forms as the range operator as well
gthb 265280e
Trim the retyping comment to the rule it implements
gthb cbb6d53
fix: a sheet range whose both ends are quoted is a range operation
gthb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -98,16 +98,20 @@ describe('lexer: 3d ranges', () => { | |
| { type: REF_RANGE, value: "'Gamma'!A1" } | ||
| ]); | ||
| }); | ||
| test('Both sections quoted independently', () => { | ||
| test('a quote on the second section leaves two references', () => { | ||
| expect(tokenize("'Alpha':'Gamma'!A1", { mergeRefs: false })).toEqual([ | ||
| { type: CONTEXT_QUOTE, value: "'Alpha'" }, | ||
| { type: OPERATOR, value: ':' }, | ||
| { type: CONTEXT_QUOTE, value: "'Gamma'" }, | ||
| { type: OPERATOR, value: '!' }, | ||
| { type: REF_RANGE, value: 'A1' } | ||
| ]); | ||
| // The quote on the second name makes the colon a range operator, so these are two | ||
| // references and are not merged. | ||
| expect(tokenize("'Alpha':'Gamma'!A1")).toEqual([ | ||
| { type: REF_RANGE, value: "'Alpha':'Gamma'!A1" } | ||
| { type: REF_NAMED, value: "'Alpha'" }, | ||
| { type: OPERATOR, value: ':' }, | ||
| { type: REF_RANGE, value: "'Gamma'!A1" } | ||
| ]); | ||
| }); | ||
| test('Both sections quoted together', () => { | ||
|
|
@@ -132,7 +136,7 @@ describe('lexer: 3d ranges', () => { | |
| { type: REF_RANGE, value: 'A1' } | ||
| ]); | ||
| expect(tokenize("'Alpha:Beta':Gamma!A1")).toEqual([ | ||
| { type: CONTEXT_QUOTE, value: "'Alpha:Beta'" }, | ||
| { type: REF_NAMED, value: "'Alpha:Beta'" }, | ||
| { type: OPERATOR, value: ':' }, | ||
| { type: REF_RANGE, value: 'Gamma!A1' } | ||
| ]); | ||
|
|
@@ -200,7 +204,7 @@ describe('lexer: 3d ranges', () => { | |
| expect(tokenize("Alpha:'Beta:Gamma':Delta!A1")).toEqual([ | ||
| { type: REF_NAMED, value: 'Alpha' }, | ||
| { type: OPERATOR, value: ':' }, | ||
| { type: CONTEXT_QUOTE, value: "'Beta:Gamma'" }, | ||
| { type: REF_NAMED, value: "'Beta:Gamma'" }, | ||
| { type: OPERATOR, value: ':' }, | ||
| { type: REF_RANGE, value: 'Delta!A1' } | ||
| ]); | ||
|
|
@@ -262,9 +266,7 @@ describe('lexer: 3d ranges', () => { | |
| ]); | ||
| }); | ||
|
|
||
| test('both sections quoted, but independently', () => { | ||
| // XXX: ensure fixranges deals with this | ||
| // Excel will correct this to `'[Book.xlsx]Alpha:Gamma'!A1` | ||
| test('a quote on the second section leaves two references, with a workbook', () => { | ||
| expect(tokenize("'[Book.xlsx]Alpha':'Gamma'!A1", { mergeRefs: false })).toEqual([ | ||
| { type: CONTEXT_QUOTE, value: "'[Book.xlsx]Alpha'" }, | ||
| { type: OPERATOR, value: ':' }, | ||
|
|
@@ -273,7 +275,9 @@ describe('lexer: 3d ranges', () => { | |
| { type: REF_RANGE, value: 'A1' } | ||
| ]); | ||
| expect(tokenize("'[Book.xlsx]Alpha':'Gamma'!A1")).toEqual([ | ||
| { type: REF_RANGE, value: "'[Book.xlsx]Alpha':'Gamma'!A1" } | ||
| { type: REF_NAMED, value: "'[Book.xlsx]Alpha'" }, | ||
| { type: OPERATOR, value: ':' }, | ||
| { type: REF_RANGE, value: "'Gamma'!A1" } | ||
| ]); | ||
| }); | ||
|
|
||
|
|
@@ -317,8 +321,10 @@ describe('lexer: 3d ranges', () => { | |
| { type: OPERATOR, value: '!' }, | ||
| { type: REF_RANGE, value: 'A1' } | ||
| ]); | ||
| // Nothing merges the first scope, because a workbook specifier is not allowed in the | ||
| // second. What is left has no `!` after it, so it is the operand Excel reads as a name. | ||
| expect(tokenize("'Alpha':[Book.xlsx]Gamma!A1")).toEqual([ | ||
| { type: CONTEXT_QUOTE, value: "'Alpha'" }, | ||
| { type: REF_NAMED, value: "'Alpha'" }, | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is still a context token, |
||
| { type: OPERATOR, value: ':' }, | ||
| { type: REF_RANGE, value: '[Book.xlsx]Gamma!A1' } | ||
| ]); | ||
|
|
@@ -380,7 +386,7 @@ describe('lexer: 3d ranges', () => { | |
| { type: REF_RANGE, value: 'A1' } | ||
| ]); | ||
| expect(tokenize("'Alpha':'[Book.xlsx]Gamma'!A1")).toEqual([ | ||
| { type: CONTEXT_QUOTE, value: "'Alpha'" }, | ||
| { type: REF_NAMED, value: "'Alpha'" }, | ||
| { type: OPERATOR, value: ':' }, | ||
| { type: REF_RANGE, value: "'[Book.xlsx]Gamma'!A1" } | ||
| ]); | ||
|
|
||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I disagree that this should parse, it is not a valid expression.
'Alpha'is not a valid name so it should not be turned into a name ref node in the AST.