Revert "Skip COMMIT_EDITMSG contents when opening the file (#24146)" (#24216)

This commit is contained in:
Kirill Bulatov 2025-02-04 21:05:10 +02:00 committed by GitHub
parent e768eb0a34
commit 3e68f7fde4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 49 additions and 111 deletions

View file

@ -1935,21 +1935,7 @@ impl Project {
}
self.buffer_store.update(cx, |buffer_store, cx| {
buffer_store.open_buffer(path.into(), false, cx)
})
}
pub fn open_buffer_without_contents(
&mut self,
path: impl Into<ProjectPath>,
cx: &mut Context<Self>,
) -> Task<Result<Entity<Buffer>>> {
if self.is_disconnected(cx) {
return Task::ready(Err(anyhow!(ErrorCode::Disconnected)));
}
self.buffer_store.update(cx, |buffer_store, cx| {
buffer_store.open_buffer(path.into(), true, cx)
buffer_store.open_buffer(path.into(), cx)
})
}
@ -3953,25 +3939,14 @@ impl Project {
) -> Result<proto::OpenBufferResponse> {
let peer_id = envelope.original_sender_id()?;
let worktree_id = WorktreeId::from_proto(envelope.payload.worktree_id);
let skip_file_contents = envelope.payload.skip_file_contents;
let open_buffer = this.update(&mut cx, |this, cx| {
if skip_file_contents {
this.open_buffer_without_contents(
ProjectPath {
worktree_id,
path: PathBuf::from(envelope.payload.path).into(),
},
cx,
)
} else {
this.open_buffer(
ProjectPath {
worktree_id,
path: PathBuf::from(envelope.payload.path).into(),
},
cx,
)
}
this.open_buffer(
ProjectPath {
worktree_id,
path: PathBuf::from(envelope.payload.path).into(),
},
cx,
)
})?;
let buffer = open_buffer.await?;
@ -4079,10 +4054,12 @@ impl Project {
.with_context(|| format!("creating commit message file {commit_message_file:?}"))?;
let (worktree, relative_path) = this
.update(&mut cx, |project, cx| {
project.worktree_store.update(cx, |worktree_store, cx| {
worktree_store.find_or_create_worktree(&commit_message_file, false, cx)
})
.update(&mut cx, |headless_project, cx| {
headless_project
.worktree_store
.update(cx, |worktree_store, cx| {
worktree_store.find_or_create_worktree(&commit_message_file, false, cx)
})
})?
.await
.with_context(|| {
@ -4090,17 +4067,18 @@ impl Project {
})?;
let buffer = this
.update(&mut cx, |project, cx| {
project.buffer_store.update(cx, |buffer_store, cx| {
buffer_store.open_buffer(
ProjectPath {
worktree_id: worktree.read(cx).id(),
path: Arc::from(relative_path),
},
true,
cx,
)
})
.update(&mut cx, |headless_project, cx| {
headless_project
.buffer_store
.update(cx, |buffer_store, cx| {
buffer_store.open_buffer(
ProjectPath {
worktree_id: worktree.read(cx).id(),
path: Arc::from(relative_path),
},
cx,
)
})
})
.with_context(|| {
format!("opening buffer for commit message file {commit_message_file:?}")