diff --git a/src/harness/fourslash.ts b/src/harness/fourslash.ts index a75a78e2a6..a9d2bc8a00 100644 --- a/src/harness/fourslash.ts +++ b/src/harness/fourslash.ts @@ -1181,12 +1181,7 @@ namespace FourSlash { })); for (const start of toArray(starts)) { - if (typeof start === "string") { - this.goToMarker(start); - } - else { - this.goToRangeStart(start); - } + this.goToMarkerOrRange(start); const fullActual = ts.map(this.findReferencesAtCaret(), ({ definition, references }, i) => { const text = definition.displayParts.map(d => d.text).join(""); return { @@ -1203,15 +1198,7 @@ namespace FourSlash { } public verifyNoReferences(markerNameOrRange?: string | Range) { - if (markerNameOrRange) { - if (ts.isString(markerNameOrRange)) { - this.goToMarker(markerNameOrRange); - } - else { - this.goToRangeStart(markerNameOrRange); - } - } - + if (markerNameOrRange) this.goToMarkerOrRange(markerNameOrRange); const refs = this.getReferencesAtCaret(); if (refs && refs.length) { this.raiseError(`Expected getReferences to fail, but saw references: ${stringify(refs)}`); @@ -2053,6 +2040,14 @@ Actual: ${stringify(fullActual)}`); this.goToPosition(len); } + private goToMarkerOrRange(markerOrRange: string | Range) { + if (typeof markerOrRange === "string") { + this.goToMarker(markerOrRange); + } else { + this.goToRangeStart(markerOrRange); + } + } + public goToRangeStart({ fileName, pos }: Range) { this.openFile(fileName); this.goToPosition(pos);