From 9e64974f13e91470be7b411285b7a33c698da3aa Mon Sep 17 00:00:00 2001 From: Skyler Hawthorne Date: Fri, 16 Sep 2022 23:32:25 -0400 Subject: remove Document::format_and_save --- helix-view/src/document.rs | 43 +++---------------------------------------- 1 file changed, 3 insertions(+), 40 deletions(-) diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs index ff64689e..4a09bedc 100644 --- a/helix-view/src/document.rs +++ b/helix-view/src/document.rs @@ -520,32 +520,12 @@ impl Document { path: Option

, force: bool, ) -> Result<(), anyhow::Error> { - self.save_impl::, _>(None, path, force) - } - - pub fn format_and_save( - &mut self, - formatting: Option, - path: Option

, - force: bool, - ) -> anyhow::Result<()> - where - F: Future> + 'static + Send, - P: Into, - { - self.save_impl(formatting, path, force) + self.save_impl::, _>(path, force) } /// The `Document`'s text is encoded according to its encoding and written to the file located /// at its `path()`. - /// - /// If `formatting` is present, it supplies some changes that we apply to the text before saving. - fn save_impl( - &mut self, - formatting: Option, - path: Option

, - force: bool, - ) -> Result<(), anyhow::Error> + fn save_impl(&mut self, path: Option

, force: bool) -> Result<(), anyhow::Error> where F: Future> + 'static + Send, P: Into, @@ -561,7 +541,7 @@ impl Document { // we clone and move text + path into the future so that we asynchronously save the current // state without blocking any further edits. - let mut text = self.text().clone(); + let text = self.text().clone(); let path = match path { Some(path) => helix_core::path::get_canonicalized_path(&path.into())?, @@ -602,23 +582,6 @@ impl Document { } } - if let Some(fmt) = formatting { - match fmt.await { - Ok(transaction) => { - let success = transaction.changes().apply(&mut text); - if !success { - // This shouldn't happen, because the transaction changes were generated - // from the same text we're saving. - log::error!("failed to apply format changes before saving"); - } - } - Err(err) => { - // formatting failed: report error, and save file without modifications - log::error!("{}", err); - } - } - } - let mut file = File::create(&path).await?; to_writer(&mut file, encoding, &text).await?; -- cgit v1.2.3-70-g09d2