-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: APIRelates to the public API for TypeScriptRelates to the public API for TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
For the file:
import fs = require('fs');
import ws = fs.writeStream;getDocumentHighlights will not find that the fs on line 1 is the same as the one on line 2.
But for the file:
import fs = require('fs');
var ws = fs.writeStream;I wrote a small program to demonstrate the problem.
var ts = require('typescript');
var fs = require('fs');
var source = fs.readFileSync('test.ts').toString();
var sourceFile = ts.createSourceFile('test.ts', source, 1, false);
var host = {
getCompilationSettings: function() {
return {
noResolve: true,
target: ts.ScriptTarget.ES5
};
},
getCurrentDirectory: function() {
return '';
},
getDefaultLibFileName: function() {
return "lib.d.ts"
},
getScriptFileNames: function() {
return ['test.ts'];
},
getScriptIsOpen: function() {
return true
},
getScriptVersion: function() {
return "1"
},
getScriptSnapshot: function() {
return {
getLength: function() {
return source.length;
},
getLineStartPositions: function () {
return ts.computeLineStarts(source);
},
getText: function(start, end) {
return source.substring(start, end);
}
};
}
};
var documentRegistry = ts.createDocumentRegistry();
var languageServices = ts.createLanguageService(host, documentRegistry);
var importFS = sourceFile.statements[0];
var highlights = languageServices.getDocumentHighlights('test.ts', importFS.name.pos + 1, ['test.ts']);
console.log(highlights[0].highlightSpans.length);When test.ts contains the first example, it outputs 1. When test.ts contains the second example, it outputs 2.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: APIRelates to the public API for TypeScriptRelates to the public API for TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue