Skip to content

Commit

Permalink
Fix Self-check
Browse files Browse the repository at this point in the history
  • Loading branch information
graphemecluster committed Sep 1, 2023
1 parent 416f31f commit 13ef487
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/compiler/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8205,7 +8205,7 @@ export function setObjectAllocator(alloc: ObjectAllocator) {

/** @internal */
export function formatStringFromArgs(text: string, args: DiagnosticArguments): string {
return text.replace(/{(\d+)}/g, (_match, index: string) => "" + Debug.checkDefined(args[+index]));
return text.replace(/\{(\d+)\}/g, (_match, index: string) => "" + Debug.checkDefined(args[+index]));
}

let localizedDiagnosticMessages: MapLike<string> | undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/harness/fourslashImpl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2699,7 +2699,7 @@ export class TestState {
},
});
}
else if (prevChar === " " && /A-Za-z_/.test(ch)) {
else if (prevChar === " " && /[A-Za-z_]/.test(ch)) {
/* Completions */
this.languageService.getCompletionsAtPosition(this.activeFile.fileName, offset, ts.emptyOptions);
}
Expand Down
2 changes: 1 addition & 1 deletion src/harness/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export function removeTestPathPrefixes(text: string, retainTrailingDirectorySepa
}

function createDiagnosticMessageReplacer<R extends (messageArgs: string[], ...args: string[]) => string[]>(diagnosticMessage: ts.DiagnosticMessage, replacer: R) {
const messageParts = diagnosticMessage.message.split(/{\d+}/g);
const messageParts = diagnosticMessage.message.split(/\{\d+\}/g);
const regExp = new RegExp(`^(?:${messageParts.map(ts.regExpEscape).join("(.*?)")})$`);
type Args<R> = R extends (messageArgs: string[], ...args: infer A) => string[] ? A : [];
return (text: string, ...args: Args<R>) => text.replace(regExp, (_, ...fixedArgs) => ts.formatStringFromArgs(diagnosticMessage.message, replacer(fixedArgs, ...args)));
Expand Down

0 comments on commit 13ef487

Please sign in to comment.