Skip to content

Commit ce50324

Browse files
committed
refactor: getInnermostScope
1 parent 53f6efe commit ce50324

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/scope/index.ts

+7-1
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,17 @@ export function getInnermostScope(
115115
node: ESTree.Node
116116
): Scope {
117117
const location = node.range![0];
118+
const isInRange =
119+
node.range![0] === node.range![1]
120+
? (range: [number, number]) =>
121+
range[0] <= location && location <= range[1]
122+
: (range: [number, number]) =>
123+
range[0] <= location && location < range[1];
118124

119125
for (const childScope of initialScope.childScopes) {
120126
const range = childScope.block.range!;
121127

122-
if (range[0] <= location && location < range[1]) {
128+
if (isInRange(range)) {
123129
return getInnermostScope(childScope, node);
124130
}
125131
}

0 commit comments

Comments
 (0)