From 09a7cc4723eab0cf80cb18897fa372faa9de5b03 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Fri, 27 Sep 2024 01:44:36 +0100 Subject: refactor(fmt): rewrite HTML syntax error handling (#25892) --- cli/Cargo.toml | 2 +- cli/tools/fmt.rs | 12 +----------- 2 files changed, 2 insertions(+), 12 deletions(-) (limited to 'cli') diff --git a/cli/Cargo.toml b/cli/Cargo.toml index b4fd053d7..21affb900 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -124,7 +124,7 @@ libz-sys.workspace = true log = { workspace = true, features = ["serde"] } lsp-types.workspace = true malva = "=0.10.1" -markup_fmt = "=0.13.0" +markup_fmt = "=0.13.1" memmem.workspace = true monch.workspace = true notify.workspace = true diff --git a/cli/tools/fmt.rs b/cli/tools/fmt.rs index a7f4fd554..8a4bc4e6c 100644 --- a/cli/tools/fmt.rs +++ b/cli/tools/fmt.rs @@ -437,25 +437,15 @@ pub fn format_html( ) .map_err(|error| match error { markup_fmt::FormatError::Syntax(error) => { - // TODO(bartlomieju): rework when better error support in `markup_fmt` lands fn inner( error: &markup_fmt::SyntaxError, file_path: &Path, ) -> Option { - let error_str = format!("{}", error); - let error_str = error_str.strip_prefix("syntax error '")?; - - let reason = error_str - .split("' at") - .collect::>() - .first() - .map(|s| s.to_string())?; - let url = Url::from_file_path(file_path).ok()?; let error_msg = format!( "Syntax error ({}) at {}:{}:{}\n", - reason, + error.kind, url.as_str(), error.line, error.column -- cgit v1.2.3