(input: string, options: ExpansionOptions)
| 44 | } |
| 45 | |
| 46 | export async function expandString(input: string, options: ExpansionOptions): Promise<string> { |
| 47 | const MAX_RECURSION: number = 10; |
| 48 | let result: string = input; |
| 49 | let didReplacement: boolean = false; |
| 50 | |
| 51 | let i: number = 0; |
| 52 | do { |
| 53 | // TODO: consider a full circular reference check? |
| 54 | [result, didReplacement] = await expandStringImpl(result, options); |
| 55 | i++; |
| 56 | } while (i < MAX_RECURSION && options.recursive && didReplacement); |
| 57 | |
| 58 | if (i === MAX_RECURSION && didReplacement) { |
| 59 | void getOutputChannelLogger().showErrorMessage(localize('max.recursion.reached', 'Reached max string expansion recursion. Possible circular reference.')); |
| 60 | } |
| 61 | |
| 62 | return replaceAll(result, '${dollar}', '$'); |
| 63 | } |
| 64 | |
| 65 | /** Returns [expandedString, didReplacement] */ |
| 66 | async function expandStringImpl(input: string, options: ExpansionOptions): Promise<[string, boolean]> { |
no test coverage detected