From 4330e5ff1439be5c0b2a88203b456379526abf84 Mon Sep 17 00:00:00 2001 From: R Aadarsh Date: Sat, 1 Nov 2025 14:53:06 +0530 Subject: [PATCH] - Change the order in which `cx` and `encoding` appear - Add a licence symlink to `encodings` --- crates/encodings/LICENSE-GPL | 1 + crates/encodings_ui/src/lib.rs | 9 ++++----- crates/project/src/buffer_store.rs | 12 +++++++++--- crates/project/src/project.rs | 4 ---- crates/remote_server/src/remote_editing_tests.rs | 2 ++ crates/workspace/src/workspace.rs | 4 +++- crates/worktree/src/worktree.rs | 2 +- crates/worktree/src/worktree_tests.rs | 4 ++-- 8 files changed, 22 insertions(+), 16 deletions(-) create mode 120000 crates/encodings/LICENSE-GPL diff --git a/crates/encodings/LICENSE-GPL b/crates/encodings/LICENSE-GPL new file mode 120000 index 0000000000000000000000000000000000000000..89e542f750cd3860a0598eff0dc34b56d7336dc4 --- /dev/null +++ b/crates/encodings/LICENSE-GPL @@ -0,0 +1 @@ +../../LICENSE-GPL \ No newline at end of file diff --git a/crates/encodings_ui/src/lib.rs b/crates/encodings_ui/src/lib.rs index bb8d2d38583bc977347c192a87e3309910519e7f..1cef23b7010e3fe2f0ad394aa7f8c23e6de7727c 100644 --- a/crates/encodings_ui/src/lib.rs +++ b/crates/encodings_ui/src/lib.rs @@ -322,11 +322,10 @@ pub fn init(cx: &mut App) { .detach(); }); - { - let force = workspace.encoding_options.force.get_mut(); - - *force = true; - } + workspace + .encoding_options + .force + .store(true, std::sync::atomic::Ordering::Release); let open_task = workspace.open_abs_path(path, OpenOptions::default(), window, cx); let weak_workspace = workspace.weak_handle(); diff --git a/crates/project/src/buffer_store.rs b/crates/project/src/buffer_store.rs index 92159a4596a15367fef5e34447c25e1f1a8b6b03..a27f7a0759f5126eac9344481a1d284252c44855 100644 --- a/crates/project/src/buffer_store.rs +++ b/crates/project/src/buffer_store.rs @@ -399,7 +399,7 @@ impl LocalBufferStore { } let save = worktree.update(cx, |worktree, cx| { - worktree.write_file(path.clone(), text, line_ending, cx, (*encoding).clone()) + worktree.write_file(path.clone(), text, line_ending, (*encoding).clone(), cx) }); cx.spawn(async move |this, cx| { @@ -643,10 +643,16 @@ impl LocalBufferStore { cx.spawn(async move |_, cx| { let loaded_file = load_file_task.await?; + let background_executor = cx.background_executor().clone(); let buffer = cx.insert_entity(reservation, |_| { Buffer::build( - text::Buffer::new(ReplicaId::LOCAL, buffer_id, loaded_file.text), + text::Buffer::new( + ReplicaId::LOCAL, + buffer_id, + loaded_file.text, + &background_executor, + ), Some(loaded_file.file), Capability::ReadWrite, ) @@ -658,7 +664,7 @@ impl LocalBufferStore { cx.spawn(async move |this, cx| { let buffer = match load_buffer.await { - Ok(buffer) => Ok(buffer), + Ok(buffer) => buffer, Err(error) if is_not_found_error(&error) => cx.new(|cx| { let buffer_id = BufferId::from(cx.entity_id().as_non_zero_u64()); let text_buffer = text::Buffer::new( diff --git a/crates/project/src/project.rs b/crates/project/src/project.rs index 0d481f487ba8f3ccabbb93f29bbc32ff3ff34c5a..69d201be295855c916915789270e695b240632fe 100644 --- a/crates/project/src/project.rs +++ b/crates/project/src/project.rs @@ -5418,12 +5418,8 @@ impl Project { rel_path.clone(), Rope::from_str(&new_text, cx.background_executor()), line_ending, - cx, Encoding::default(), - new_text.into(), - line_ending, cx, - Encoding::default(), ) })? .await diff --git a/crates/remote_server/src/remote_editing_tests.rs b/crates/remote_server/src/remote_editing_tests.rs index fffb6ae2d560afdd58baac543c061c3ad03eab98..ae8235b6559e40e07de13031fbb7b44f0d1762ed 100644 --- a/crates/remote_server/src/remote_editing_tests.rs +++ b/crates/remote_server/src/remote_editing_tests.rs @@ -35,6 +35,8 @@ use std::{ use unindent::Unindent as _; use util::{path, rel_path::rel_path}; +use gpui::SharedString; + #[gpui::test] async fn test_basic_remote_editing(cx: &mut TestAppContext, server_cx: &mut TestAppContext) { let fs = FakeFs::new(server_cx.executor()); diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index c1508a74f8603cab1b98526e06218ef474ee0645..8fc2432429f6b9f08ede6453a8772f87431b6de8 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -7622,7 +7622,9 @@ pub fn create_and_open_local_file( fs.create_file(path, Default::default()).await?; fs.save( path, - &default_content(), + &default_content(cx), + + Default::default(), Default::default(), ) diff --git a/crates/worktree/src/worktree.rs b/crates/worktree/src/worktree.rs index f8366dacb4dfd13cfb3415b5fefc494f3aa33723..b4ceceda3f6f32849e414511adcfca2d3dd6c20c 100644 --- a/crates/worktree/src/worktree.rs +++ b/crates/worktree/src/worktree.rs @@ -737,8 +737,8 @@ impl Worktree { path: Arc, text: Rope, line_ending: LineEnding, - cx: &Context, encoding: Encoding, + cx: &Context, ) -> Task>> { match self { Worktree::Local(this) => this.write_file(path, text, line_ending, cx, encoding), diff --git a/crates/worktree/src/worktree_tests.rs b/crates/worktree/src/worktree_tests.rs index cf049793ec9b47e8d24b4138fb352246c8697968..673764bbba9ca2fbca70655c96d7fe426fc83111 100644 --- a/crates/worktree/src/worktree_tests.rs +++ b/crates/worktree/src/worktree_tests.rs @@ -734,8 +734,8 @@ async fn test_write_file(cx: &mut TestAppContext) { rel_path("tracked-dir/file.txt").into(), Rope::from_str("hello", cx.background_executor()), Default::default(), - cx, Default::default(), + cx, ) }) .await @@ -746,8 +746,8 @@ async fn test_write_file(cx: &mut TestAppContext) { rel_path("ignored-dir/file.txt").into(), Rope::from_str("world", cx.background_executor()), Default::default(), - cx, Default::default(), + cx, ) }) .await