From 23d8dfc4fd01a3c2ee98cf7e82a01118ff573679 Mon Sep 17 00:00:00 2001 From: David Sherret Date: Sat, 13 Jan 2024 20:40:33 -0500 Subject: [PATCH] chore: dprint-core 0.65 (#3) --- Cargo.toml | 2 +- rust-toolchain.toml | 2 +- src/wasm_plugin.rs | 14 ++++++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index ae8392a..25b3570 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -25,7 +25,7 @@ wasm = ["dprint-core/wasm"] [dependencies] anyhow = "1.0.51" -dprint-core = { version = "0.63.3", features = ["formatting"] } +dprint-core = { version = "0.65.0", features = ["formatting"] } jsonc-parser = "0.23.0" serde = { version = "1.0.108", features = ["derive"] } serde_json = "1.0" diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 7737e53..f743517 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.74.0" +channel = "1.75.0" components = ["clippy", "rustfmt"] diff --git a/src/wasm_plugin.rs b/src/wasm_plugin.rs index 450bedb..597ac6c 100644 --- a/src/wasm_plugin.rs +++ b/src/wasm_plugin.rs @@ -48,13 +48,19 @@ impl SyncPluginHandler for JupyterPluginHandler { fn format( &mut self, _file_path: &Path, - file_text: &str, + file_bytes: Vec, _config: &Configuration, - mut format_with_host: impl FnMut(&Path, String, &ConfigKeyMap) -> FormatResult, + mut format_with_host: impl FnMut(&Path, Vec, &ConfigKeyMap) -> FormatResult, ) -> FormatResult { - super::format_text(file_text, |path, text| { - format_with_host(path, text, &ConfigKeyMap::new()) + let file_text = String::from_utf8(file_bytes)?; + super::format_text(&file_text, |path, text| { + let maybe_bytes = format_with_host(path, text.into_bytes(), &ConfigKeyMap::new())?; + match maybe_bytes { + Some(bytes) => Ok(Some(String::from_utf8(bytes)?)), + None => Ok(None), + } }) + .map(|maybe_file_text| maybe_file_text.map(|file_text| file_text.into_bytes())) } }