WIP: Get the type checker passing...
...but not the borrow checker! Co-Authored-By: Max Brunsfeld <max@zed.dev>
This commit is contained in:
co-authored by
Max Brunsfeld
parent
0e9441e5cd
commit
7b98fb33dd
+7
-12
@@ -3,7 +3,7 @@ mod fuzzy;
|
||||
mod ignore;
|
||||
|
||||
use crate::{
|
||||
editor::{History, Snapshot as BufferSnapshot},
|
||||
editor::History,
|
||||
sum_tree::{self, Cursor, Edit, SeekBias, SumTree},
|
||||
};
|
||||
use ::ignore::gitignore::Gitignore;
|
||||
@@ -16,6 +16,7 @@ use postage::{
|
||||
prelude::{Sink, Stream},
|
||||
watch,
|
||||
};
|
||||
use ropey::Rope;
|
||||
use smol::channel::Sender;
|
||||
use std::{
|
||||
cmp,
|
||||
@@ -198,20 +199,15 @@ impl Worktree {
|
||||
})
|
||||
}
|
||||
|
||||
pub fn save<'a>(
|
||||
&self,
|
||||
path: &Path,
|
||||
content: BufferSnapshot,
|
||||
ctx: &AppContext,
|
||||
) -> Task<Result<()>> {
|
||||
pub fn save<'a>(&self, path: &Path, content: Rope, ctx: &AppContext) -> Task<Result<()>> {
|
||||
let handles = self.handles.clone();
|
||||
let path = path.to_path_buf();
|
||||
let abs_path = self.absolutize(&path);
|
||||
ctx.background_executor().spawn(async move {
|
||||
let buffer_size = content.text_summary().bytes.min(10 * 1024);
|
||||
let buffer_size = content.len_bytes().min(10 * 1024);
|
||||
let file = fs::File::create(&abs_path)?;
|
||||
let mut writer = io::BufWriter::with_capacity(buffer_size, &file);
|
||||
for chunk in content.fragments() {
|
||||
for chunk in content.chunks() {
|
||||
writer.write(chunk.as_bytes())?;
|
||||
}
|
||||
writer.flush()?;
|
||||
@@ -459,7 +455,7 @@ impl FileHandle {
|
||||
self.worktree.read(ctx).load_history(&self.path(), ctx)
|
||||
}
|
||||
|
||||
pub fn save<'a>(&self, content: BufferSnapshot, ctx: &AppContext) -> Task<Result<()>> {
|
||||
pub fn save<'a>(&self, content: Rope, ctx: &AppContext) -> Task<Result<()>> {
|
||||
let worktree = self.worktree.read(ctx);
|
||||
worktree.save(&self.path(), content, ctx)
|
||||
}
|
||||
@@ -538,10 +534,9 @@ impl Entry {
|
||||
}
|
||||
|
||||
impl sum_tree::Item for Entry {
|
||||
type Context = ();
|
||||
type Summary = EntrySummary;
|
||||
|
||||
fn summary(&self, _: &()) -> Self::Summary {
|
||||
fn summary(&self) -> Self::Summary {
|
||||
let file_count;
|
||||
let visible_file_count;
|
||||
if self.is_file() {
|
||||
|
||||
Reference in New Issue
Block a user