mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
Strip colors before matching preview diagnostics
This commit is contained in:
parent
c3e4bc3136
commit
738ce83d85
1 changed files with 4 additions and 2 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import * as anser from "anser";
|
||||||
import * as lc from "vscode-languageclient/node";
|
import * as lc from "vscode-languageclient/node";
|
||||||
import * as vscode from "vscode";
|
import * as vscode from "vscode";
|
||||||
import * as ra from "../src/lsp_ext";
|
import * as ra from "../src/lsp_ext";
|
||||||
|
@ -139,9 +140,10 @@ export async function createClient(
|
||||||
?.rendered;
|
?.rendered;
|
||||||
if (rendered) {
|
if (rendered) {
|
||||||
if (preview) {
|
if (preview) {
|
||||||
|
const decolorized = anser.ansiToText(rendered);
|
||||||
const index =
|
const index =
|
||||||
rendered.match(/^(note|help):/m)?.index || rendered.length;
|
decolorized.match(/^(note|help):/m)?.index || rendered.length;
|
||||||
diag.message = rendered
|
diag.message = decolorized
|
||||||
.substring(0, index)
|
.substring(0, index)
|
||||||
.replace(/^ -->[^\n]+\n/m, "");
|
.replace(/^ -->[^\n]+\n/m, "");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue