mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-29 21:49:33 +00:00
Remove use of current File
for new buffers that never have File
(#20832)
`create_buffer` calls `Buffer::local` which sets `file` to `None`
[here](f12981db32/crates/language/src/buffer.rs (L629)
).
So there's no point in then immediately attempting to update maps that
rely on `file` being present.
Release Notes:
- N/A
This commit is contained in:
parent
8666ec95ba
commit
b4c2f29c8b
1 changed files with 0 additions and 18 deletions
|
@ -902,30 +902,12 @@ impl BufferStoreImpl for Model<LocalBufferStore> {
|
|||
}
|
||||
|
||||
fn create_buffer(&self, cx: &mut ModelContext<BufferStore>) -> Task<Result<Model<Buffer>>> {
|
||||
let handle = self.clone();
|
||||
cx.spawn(|buffer_store, mut cx| async move {
|
||||
let buffer = cx.new_model(|cx| {
|
||||
Buffer::local("", cx).with_language(language::PLAIN_TEXT.clone(), cx)
|
||||
})?;
|
||||
buffer_store.update(&mut cx, |buffer_store, cx| {
|
||||
buffer_store.add_buffer(buffer.clone(), cx).log_err();
|
||||
let buffer_id = buffer.read(cx).remote_id();
|
||||
handle.update(cx, |this, cx| {
|
||||
if let Some(file) = File::from_dyn(buffer.read(cx).file()) {
|
||||
this.local_buffer_ids_by_path.insert(
|
||||
ProjectPath {
|
||||
worktree_id: file.worktree_id(cx),
|
||||
path: file.path.clone(),
|
||||
},
|
||||
buffer_id,
|
||||
);
|
||||
|
||||
if let Some(entry_id) = file.entry_id {
|
||||
this.local_buffer_ids_by_entry_id
|
||||
.insert(entry_id, buffer_id);
|
||||
}
|
||||
}
|
||||
});
|
||||
})?;
|
||||
Ok(buffer)
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue