Skip to content

Commit 405a9ef

Browse files
author
Claus Reinke
committed
fix #54 ("definitions" with no available info)
1 parent 0e2dd92 commit 405a9ef

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

bin/tss.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -306,14 +306,14 @@ var TSS = (function () {
306306
file = _this.resolveRelativePath(m[3]);
307307
pos = _this.fileCache.lineColToPosition(file, line, col);
308308
locs = _this.ls.getDefinitionAtPosition(file, pos); // NOTE: multiple definitions
309-
info = locs.map(function (def) { return ({
309+
info = locs && locs.map(function (def) { return ({
310310
def: def,
311311
file: def && def.fileName,
312312
min: def && _this.fileCache.positionToLineCol(def.fileName, def.textSpan.start),
313313
lim: def && _this.fileCache.positionToLineCol(def.fileName, ts.textSpanEnd(def.textSpan))
314314
}); });
315315
// TODO: what about multiple definitions?
316-
_this.output(info[0] || null);
316+
_this.output((locs && info[0]) || null);
317317
}
318318
else if (m = match(cmd, /^(references|occurrences) (\d+) (\d+) (.*)$/)) {
319319
line = parseInt(m[2]);

ftplugin/typescript_tss.vim

+3-3
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,10 @@ function! TSSdef(cmd)
162162
let info = TSScmd("definition",{})
163163
if type(info)!=type({}) || info.file=='null' || type(info.min)!=type({})
164164
\ || type(info.min.line)!=type(0) || type(info.min.character)!=type(0)
165-
if type(info)==type("")
166-
echoerr info
167-
else
165+
if type(info)==type("") && info=='null'
168166
echoerr 'no useable definition information'
167+
else
168+
echoerr string(info)
169169
endif
170170
return info
171171
endif

tss.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -374,15 +374,15 @@ class TSS {
374374
pos = this.fileCache.lineColToPosition(file,line,col);
375375
locs = this.ls.getDefinitionAtPosition(file, pos); // NOTE: multiple definitions
376376

377-
info = locs.map( def => ({
377+
info = locs && locs.map( def => ({
378378
def : def,
379379
file : def && def.fileName,
380380
min : def && this.fileCache.positionToLineCol(def.fileName,def.textSpan.start),
381381
lim : def && this.fileCache.positionToLineCol(def.fileName,ts.textSpanEnd(def.textSpan))
382382
}));
383383

384384
// TODO: what about multiple definitions?
385-
this.output(info[0]||null);
385+
this.output((locs && info[0])||null);
386386

387387
} else if (m = match(cmd,/^(references|occurrences) (\d+) (\d+) (.*)$/)) {
388388

0 commit comments

Comments
 (0)