Skip to content

Commit 71e6f3a

Browse files
author
Tien Nguyen
committed
Address PR feedback.
1 parent 8550c7d commit 71e6f3a

File tree

4 files changed

+33
-12
lines changed

4 files changed

+33
-12
lines changed

src/harness/fourslash.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2128,8 +2128,7 @@ module FourSlash {
21282128
this.raiseError('verifyOccurancesAtPositionListContains failed - found 0 references, expected at least one.');
21292129
}
21302130

2131-
for (let i = 0; i < occurrences.length; i++) {
2132-
let occurrence = occurrences[i];
2131+
for (let occurrence of occurrences) {
21332132
if (occurrence && occurrence.fileName === fileName && occurrence.textSpan.start === start && ts.textSpanEnd(occurrence.textSpan) === end) {
21342133
if (typeof isWriteAccess !== "undefined" && occurrence.isWriteAccess !== isWriteAccess) {
21352134
this.raiseError('verifyOccurrencesAtPositionListContains failed - item isWriteAccess value does not match, actual: ' + occurrence.isWriteAccess + ', expected: ' + isWriteAccess + '.');
@@ -2189,9 +2188,8 @@ module FourSlash {
21892188
this.taoInvalidReason = 'verifyDocumentHighlightsAtPositionListCount NYI';
21902189

21912190
let documentHighlights = this.getDocumentHighlightsAtCurrentPosition(fileNamesToSearch);
2192-
let actualCount = documentHighlights
2193-
? documentHighlights.reduce((currentCount, { fileName, highlightSpans }) => {
2194-
return currentCount + highlightSpans.length}, 0)
2191+
let actualCount = documentHighlights
2192+
? documentHighlights.reduce((currentCount, { highlightSpans }) => currentCount + highlightSpans.length, 0)
21952193
: 0;
21962194

21972195
if (expectedCount !== actualCount) {

src/server/client.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -534,20 +534,20 @@ namespace ts.server {
534534
let request = this.processRequest<protocol.DocumentHighlightsRequest>(CommandNames.DocumentHighlights, args);
535535
let response = this.processResponse<protocol.DocumentHighlightsResponse>(request);
536536

537-
let _self = this;
537+
let self = this;
538538
return response.body.map(convertToDocumentHighlights);
539539

540540
function convertToDocumentHighlights(item: ts.server.protocol.DocumentHighlightsItem): ts.DocumentHighlights {
541541
let { file, highlightSpans } = item;
542542

543543
return {
544544
fileName: file,
545-
highlightSpans: highlightSpans.map(convertHighlightSpan2)
545+
highlightSpans: highlightSpans.map(convertHighlightSpan)
546546
};
547547

548-
function convertHighlightSpan2(span: ts.server.protocol.HighlightSpan): ts.HighlightSpan {
549-
let start = _self.lineOffsetToPosition(file, span.start);
550-
let end = _self.lineOffsetToPosition(file, span.end);
548+
function convertHighlightSpan(span: ts.server.protocol.HighlightSpan): ts.HighlightSpan {
549+
let start = self.lineOffsetToPosition(file, span.start);
550+
let end = self.lineOffsetToPosition(file, span.end);
551551
return {
552552
textSpan: ts.createTextSpanFromBounds(start, end),
553553
kind: span.kind

src/server/session.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,10 @@ namespace ts.server {
369369

370370
return {
371371
file: fileName,
372-
highlightSpans: highlightSpans.map(convertHighlightSpan1)
372+
highlightSpans: highlightSpans.map(convertHighlightSpan)
373373
};
374374

375-
function convertHighlightSpan1(highlightSpan: ts.HighlightSpan): ts.server.protocol.HighlightSpan {
375+
function convertHighlightSpan(highlightSpan: ts.HighlightSpan): ts.server.protocol.HighlightSpan {
376376
let { textSpan, kind } = highlightSpan;
377377
let start = compilerService.host.positionToLineOffset(fileName, textSpan.start);
378378
let end = compilerService.host.positionToLineOffset(fileName, ts.textSpanEnd(textSpan));
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/// <reference path="../fourslash.ts"/>
2+
3+
// @Filename: a.ts
4+
////function foo() {
5+
//// return 1;
6+
////}
7+
8+
// @Filename: b.ts
9+
/////// <reference path="a.ts"/>
10+
////[|foo|]();
11+
12+
13+
let ranges = test.ranges();
14+
15+
for (let r of ranges) {
16+
goTo.position(r.start);
17+
verify.documentHighlightsAtPositionCount(2, ["b.ts"]);
18+
19+
/*for (let range of ranges) {
20+
verify.documentHighlightsAtPositionContains(range, ["a.ts"]);
21+
}*/
22+
}
23+

0 commit comments

Comments
 (0)