Skip to content

Commit

Permalink
Fix off-by one error
Browse files Browse the repository at this point in the history
  • Loading branch information
hildjj committed Jul 7, 2022
1 parent 7afbc8e commit f769eb4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/grammar-location.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class GrammarLocation {
*/
offset(loc) {
return {
line: loc.line + this.start.line,
line: loc.line + this.start.line - 1,
column: (loc.line === 1)
? loc.column + this.start.column - 1
: loc.column,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"benchmark": "node ./benchmark/run_bench.js",
"rollup": "copyfiles package.json build/ts && rollup -c",
"terser": "npm run terser:peggy && npm run terser:tests && npm run terser:bench",
"terser:peggy": "terser -c passes=2 -m --sequences 40 build/rollup/peggy.umd.js -o build/peggy.min.js",
"terser:peggy": "terser -c passes=2 -m reserved=['GrammarLocation'] --sequences 40 build/rollup/peggy.umd.js -o build/peggy.min.js",
"terser:tests": "terser -c passes=2 -m --sequences 40 --module build/rollup/test.umd.js -o build/test-bundle.min.js",
"terser:bench": "terser -c passes=2 -m --sequences 40 --module build/rollup/benchmark.umd.js -o build/benchmark-bundle.min.js",
"headers": "node ./tools/header.js build/peggy.min.js build/benchmark-bundle.min.js build/test-bundle.min.js",
Expand Down
20 changes: 10 additions & 10 deletions test/unit/grammar-error.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,30 +182,30 @@ note: Warning Subinfo
});
expect(e.format([{ source: gl, text: source.text }])).to.equal(`\
error: message
--> foo.peggy:16:8
--> foo.peggy:15:8
|
16 | some error
15 | some error
| ^^^^
note: Subinfo
--> foo.peggy:16:13
--> foo.peggy:15:13
|
16 | some error
15 | some error
| ^^^^^
note: Column not offset
--> foo.peggy:17:1
--> foo.peggy:16:1
|
17 | that
16 | that
| ^^^^
warning: Warning message
--> foo.peggy:16:13
--> foo.peggy:15:13
|
16 | some error
15 | some error
| ^^^^^
note: Warning Subinfo
--> foo.peggy:16:13
--> foo.peggy:15:13
|
16 | some error
15 | some error
| ^^^^^`);
location.source = "foo.peggy";
subSpan.source = "foo.peggy";
Expand Down

0 comments on commit f769eb4

Please sign in to comment.