- Change the order in which `cx` and `encoding` appear

R Aadarsh created

- Add a licence symlink to `encodings`

Change summary

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(-)

Detailed changes

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();

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(

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

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());

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(),
             )

crates/worktree/src/worktree.rs 🔗

@@ -737,8 +737,8 @@ impl Worktree {
         path: Arc<RelPath>,
         text: Rope,
         line_ending: LineEnding,
-        cx: &Context<Worktree>,
         encoding: Encoding,
+        cx: &Context<Worktree>,
     ) -> Task<Result<Arc<File>>> {
         match self {
             Worktree::Local(this) => this.write_file(path, text, line_ending, cx, encoding),

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