import * as vscode from 'vscode'; /** Current text of a document: the open editor buffer, else the file on disk. */ export async function readText(uri: vscode.Uri): Promise { const open = vscode.workspace.textDocuments.find((doc) => doc.uri.toString() === uri.toString()); if (open) return open.getText(); return new TextDecoder('utf-8').decode(await vscode.workspace.fs.readFile(uri)); }