mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-06-10 18:04:18 -05:00
Allow singleline string writer to be recursively used (#18297)
* Allow singleline string writer to be recursively used * Add unit test exposing issue * Fix lints
This commit is contained in:
@@ -32,7 +32,6 @@ namespace ts {
|
||||
}
|
||||
|
||||
const stringWriter = createSingleLineStringWriter();
|
||||
let stringWriterAcquired = false;
|
||||
|
||||
function createSingleLineStringWriter(): StringSymbolWriter {
|
||||
let str = "";
|
||||
@@ -62,15 +61,14 @@ namespace ts {
|
||||
}
|
||||
|
||||
export function usingSingleLineStringWriter(action: (writer: StringSymbolWriter) => void): string {
|
||||
const oldString = stringWriter.string();
|
||||
try {
|
||||
Debug.assert(!stringWriterAcquired);
|
||||
stringWriterAcquired = true;
|
||||
action(stringWriter);
|
||||
return stringWriter.string();
|
||||
}
|
||||
finally {
|
||||
stringWriter.clear();
|
||||
stringWriterAcquired = false;
|
||||
stringWriter.writeKeyword(oldString);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user