diff --git a/src/tools/meson.ts b/src/tools/meson.ts index cfc2df2..9ab9154 100644 --- a/src/tools/meson.ts +++ b/src/tools/meson.ts @@ -17,7 +17,10 @@ export async function format(meson: Tool, root: string, document: vscode.TextDoc const { stdout, stderr, error } = await execFeed(meson.path, args, { cwd: root }, originalDocumentText); if (error) { - getOutputChannel().appendLine(`Failed to format document with meson: ${stderr}`); + //TODO: file a bug report, meson prints some errors on stdout :( + const errorString = stderr.trim().length > 0 ? stderr : stdout; + + getOutputChannel().appendLine(`Failed to format document with meson: ${errorString}`); getOutputChannel().show(true); return []; } @@ -31,6 +34,7 @@ export async function format(meson: Tool, root: string, document: vscode.TextDoc } const formattingSupportedSinceVersion = new Version([1, 5, 0]); +const formattingWithStdinSupportedSinceVersion = new Version([1, 7, 0]); export async function check(): Promise { const meson_path = mesonProgram(); @@ -52,5 +56,12 @@ export async function check(): Promise { ); } + // using "-" as stdin is only supported since 1.7.0 (see https://github.com/mesonbuild/meson/pull/13793) + if (mesonVersion.compareWithOther(formattingWithStdinSupportedSinceVersion) < 0) { + return ToolCheckResult.newError( + `Meson supports formatting from stdin only since version ${formattingWithStdinSupportedSinceVersion}, but you have version ${mesonVersion}`, + ); + } + return ToolCheckResult.newTool({ path: meson_path, version: mesonVersion }); }