Skip to content

Commit 3160b5c

Browse files
authored
Don’t require fourslash completions tests to specify replacementSpan when it’s zero-length (#42013)
1 parent c73e480 commit 3160b5c

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

src/harness/fourslashImpl.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -907,11 +907,13 @@ namespace FourSlash {
907907
this.raiseError(`Expected completion insert text to be ${expected.insertText}, got ${actual.insertText}`);
908908
}
909909
const convertedReplacementSpan = expected.replacementSpan && ts.createTextSpanFromRange(expected.replacementSpan);
910-
try {
911-
assert.deepEqual(actual.replacementSpan, convertedReplacementSpan);
912-
}
913-
catch {
914-
this.raiseError(`Expected completion replacementSpan to be ${stringify(convertedReplacementSpan)}, got ${stringify(actual.replacementSpan)}`);
910+
if (convertedReplacementSpan?.length) {
911+
try {
912+
assert.deepEqual(actual.replacementSpan, convertedReplacementSpan);
913+
}
914+
catch {
915+
this.raiseError(`Expected completion replacementSpan to be ${stringify(convertedReplacementSpan)}, got ${stringify(actual.replacementSpan)}`);
916+
}
915917
}
916918

917919
if (expected.kind !== undefined || expected.kindModifiers !== undefined) {

tests/cases/fourslash/completionsWithGenericStringLiteral.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,9 @@
22
// @strict: true
33

44
//// declare function get<T, K extends keyof T>(obj: T, key: K): T[K];
5-
//// get({ hello: 123, world: 456 }, "[|/**/|]");
5+
//// get({ hello: 123, world: 456 }, "/**/");
66

77
verify.completions({
88
marker: "",
9-
includes: [
10-
{ name: 'hello', replacementSpan: test.ranges()[0] },
11-
{ name: 'world', replacementSpan: test.ranges()[0] }
12-
]
9+
includes: ["hello", "world"]
1310
});

0 commit comments

Comments
 (0)