Skip to content

Commit

Permalink
🐛 fix wrong locations for filters syntax with line breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
mysticatea committed Dec 1, 2018
1 parent a6135f8 commit 595b9ae
Show file tree
Hide file tree
Showing 8 changed files with 789 additions and 12 deletions.
9 changes: 4 additions & 5 deletions src/script/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -461,16 +461,15 @@ function parseFilter(
range: [callee.range[0], callee.range[1] - 2],
loc: {
start: callee.loc.start,
end: {
line: callee.loc.end.line,
column: callee.loc.end.column - 2,
},
end: locationCalculator.getLocation(
callee.range[1] - callee.range[0] - 1,
),
},
name: String(callee.value),
}
tokens.push({
type: "Identifier",
value: calleeCode,
value: calleeCode.trim(),
range: expression.callee.range,
loc: expression.callee.loc,
})
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/ast/filters-2/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@
},
{
"type": "Identifier",
"value": " f1 ",
"value": "f1",
"range": [
31,
33
Expand Down Expand Up @@ -591,7 +591,7 @@
},
{
"type": "Identifier",
"value": " f2",
"value": "f2",
"range": [
36,
38
Expand Down Expand Up @@ -667,7 +667,7 @@
},
{
"type": "Identifier",
"value": " f3",
"value": "f3",
"range": [
43,
45
Expand Down
6 changes: 3 additions & 3 deletions test/fixtures/ast/filters-3/ast.json
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@
},
{
"type": "Identifier",
"value": " f1 ",
"value": "f1",
"range": [
35,
37
Expand Down Expand Up @@ -653,7 +653,7 @@
},
{
"type": "Identifier",
"value": " f2",
"value": "f2",
"range": [
40,
42
Expand Down Expand Up @@ -729,7 +729,7 @@
},
{
"type": "Identifier",
"value": " f3",
"value": "f3",
"range": [
47,
49
Expand Down

0 comments on commit 595b9ae

Please sign in to comment.