From 738ce83d858aa498c3ff28be3417101ab5f9ce6f Mon Sep 17 00:00:00 2001 From: Ian Chamberlain Date: Tue, 3 Jan 2023 10:49:47 -0500 Subject: [PATCH] Strip colors before matching preview diagnostics --- editors/code/src/client.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/editors/code/src/client.ts b/editors/code/src/client.ts index 74cf44f42f..c6d64ebc1e 100644 --- a/editors/code/src/client.ts +++ b/editors/code/src/client.ts @@ -1,3 +1,4 @@ +import * as anser from "anser"; import * as lc from "vscode-languageclient/node"; import * as vscode from "vscode"; import * as ra from "../src/lsp_ext"; @@ -139,9 +140,10 @@ export async function createClient( ?.rendered; if (rendered) { if (preview) { + const decolorized = anser.ansiToText(rendered); const index = - rendered.match(/^(note|help):/m)?.index || rendered.length; - diag.message = rendered + decolorized.match(/^(note|help):/m)?.index || rendered.length; + diag.message = decolorized .substring(0, index) .replace(/^ -->[^\n]+\n/m, ""); }