-
Notifications
You must be signed in to change notification settings - Fork 374
Open
Description
Discovered a small issue in tern when files are not loaded in order. Jump to definition gives the right position but wrong filename. Found it and fixed it but no time to clone && make a pull request for something so small :). Thanks y'all for good software.
The issue crops when you have files like;
a.js
var c;
function b(a){
c = a
}
b.js
b({hello:'hi'})
c.js
c.hello
If files are loaded in this order c.js>b.js>a.js, jumpToDef on 'hello' takes you to a.js.
Here's my ignorant quick fix.
if (span && span.node) { // refers to a loaded file
var spanFile = span.node.sourceFile || srv.fileMap[span.origin];
var start = outputPos(query, spanFile, span.node.start), end = outputPos(query, spanFile, span.node.end);
result.start = start; result.end = end;
---result.file = span.origin
+++result.file = (spanFile && spanFile.name)||span.origin;
var cxStart = Math.max(0, span.node.start - 50);
result.contextOffset = span.node.start - cxStart;
result.context = spanFile.text.slice(cxStart, cxStart + 50);
} else if (span) { // external
result.file = span.origin;
storeSpan(srv, query, span, result);
}
Metadata
Metadata
Assignees
Labels
No labels