@@ -520,32 +520,12 @@ impl Document {
520 path: Option<P>,
520 path: Option<P>,
521 force: bool,
521 force: bool,
522 ) -> Result<(), anyhow::Error> {
522 ) -> Result<(), anyhow::Error> {
523− self.save_impl::<futures_util::future::Ready<_>, _>(None, path, force)
523+ self.save_impl::<futures_util::future::Ready<_>, _>(path, force)
526− pub fn format_and_save<F, P>(
528− formatting: Option<F>,
531− ) -> anyhow::Result<()>
533− F: Future<Output = Result<Transaction, FormatterError>> + 'static + Send,
536− self.save_impl(formatting, path, force)
539 /// The `Document`'s text is encoded according to its encoding and written to the file located
526 /// The `Document`'s text is encoded according to its encoding and written to the file located
540 /// at its `path()`.
527 /// at its `path()`.
542− /// If `formatting` is present, it supplies some changes that we apply to the text before saving.
545− formatting: Option<F>,
548− ) -> Result<(), anyhow::Error>
528+ fn save_impl<F, P>(&mut self, path: Option<P>, force: bool) -> Result<(), anyhow::Error>
550 F: Future<Output = Result<Transaction, FormatterError>> + 'static + Send,
530 F: Future<Output = Result<Transaction, FormatterError>> + 'static + Send,
551 P: Into<PathBuf>,
531 P: Into<PathBuf>,
@@ -561,7 +541,7 @@ impl Document {
562 // we clone and move text + path into the future so that we asynchronously save the current
542 // we clone and move text + path into the future so that we asynchronously save the current
563 // state without blocking any further edits.
543 // state without blocking any further edits.
564− let mut text = self.text().clone();
544+ let text = self.text().clone();
566 let path = match path {
546 let path = match path {
567 Some(path) => helix_core::path::get_canonicalized_path(&path.into())?,
547 Some(path) => helix_core::path::get_canonicalized_path(&path.into())?,
@@ -602,23 +582,6 @@ impl Document {
605− if let Some(fmt) = formatting {
607− Ok(transaction) => {
608− let success = transaction.changes().apply(&mut text);
610− // This shouldn't happen, because the transaction changes were generated
611− // from the same text we're saving.
612− log::error!("failed to apply format changes before saving");
616− // formatting failed: report error, and save file without modifications
617− log::error!("{}", err);
622 let mut file = File::create(&path).await?;
585 let mut file = File::create(&path).await?;
623 to_writer(&mut file, encoding, &text).await?;
586 to_writer(&mut file, encoding, &text).await?;