Skip to content

Commit f861509

Browse files
committed
fix(parser): adjust distance comparison for closest declarations in MapParser
1 parent 1a2e2ac commit f861509

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/parsers/MapParser.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,15 +158,15 @@ export default class MapParser {
158158
if (declFunc && declFunc.name === currentFunc.name) {
159159
// Same function - local takes precedence
160160
const distance = targetLine - decl.line;
161-
if (distance < closestDistance) {
161+
if (distance <= closestDistance) {
162162
closestDistance = distance;
163163
closestDecl = decl;
164164
}
165165
} else if (!declFunc && decl.scope.toLowerCase() === 'global') {
166166
// Global declaration, but only use if no local found
167167
if (closestDecl === null || closestDecl.scope.toLowerCase() !== 'local') {
168168
const distance = targetLine - decl.line;
169-
if (distance < closestDistance) {
169+
if (distance <= closestDistance) {
170170
closestDistance = distance;
171171
closestDecl = decl;
172172
}
@@ -212,7 +212,9 @@ export default class MapParser {
212212
}
213213

214214
const directKeys = Array.from(validKeys);
215-
const functionKeys = includeFunctionKeys ? this.getKeysFromFunctionCalls(mapName, targetLine) : [];
215+
const functionKeys = includeFunctionKeys
216+
? this.getKeysFromFunctionCalls(mapName, targetLine)
217+
: [];
216218

217219
return { directKeys, functionKeys };
218220
}

0 commit comments

Comments
 (0)