Add a new load_with_encoding function to handle files with various encodings.

Modified `Buffer::reload` in `buffer.rs` to use this new function, allowing Zed
to open files with any encoding in UTF-8 mode. Files with characters that
are invalid in UTF-8 will have those bytes replaced with the � character.

Add comments and documentation.
This commit is contained in:
R Aadarsh 2025-08-25 12:39:12 +05:30
parent 43357f689c
commit 0e1f9f689c
10 changed files with 112 additions and 21 deletions

View file

@ -1193,6 +1193,7 @@ async fn get_copilot_lsp(fs: Arc<dyn Fs>, node_runtime: NodeRuntime) -> anyhow::
#[cfg(test)]
mod tests {
use super::*;
use encoding::Encoding;
use gpui::TestAppContext;
use util::path;
@ -1406,6 +1407,10 @@ mod tests {
fn load_bytes(&self, _cx: &App) -> Task<Result<Vec<u8>>> {
unimplemented!()
}
fn load_with_encoding(&self, _: &App, _: &'static dyn Encoding) -> Task<Result<String>> {
unimplemented!()
}
}
}