Re-Add `load_with_encoding` method to the `Fs` trait

R Aadarsh created

Change summary

crates/fs/src/fs.rs | 10 ++++++++++
1 file changed, 10 insertions(+)

Detailed changes

crates/fs/src/fs.rs 🔗

@@ -62,6 +62,7 @@ use std::ffi::OsStr;
 
 #[cfg(any(test, feature = "test-support"))]
 pub use fake_git_repo::{LOAD_HEAD_TEXT_TASK, LOAD_INDEX_TEXT_TASK};
+use crate::encodings::to_utf8;
 use crate::encodings::EncodingWrapper;
 use crate::encodings::from_utf8;
 
@@ -120,6 +121,15 @@ pub trait Fs: Send + Sync {
         Ok(String::from_utf8(self.load_bytes(path).await?)?)
     }
 
+    async fn load_with_encoding(
+        &self,
+        path: &Path,
+        encoding: EncodingWrapper,
+        detect_utf16: bool,
+    ) -> Result<String> {
+        Ok(to_utf8(self.load_bytes(path).await?, encoding, detect_utf16, None).await?)
+    }
+
     async fn load_bytes(&self, path: &Path) -> Result<Vec<u8>>;
     async fn atomic_write(&self, path: PathBuf, text: String) -> Result<()>;
     async fn save(