Skip COMMIT_EDITMSG contents when opening the file (#24146)
This commit is contained in:
parent
225f0c4d12
commit
ea66a54cf8
9 changed files with 110 additions and 48 deletions
|
@ -1933,7 +1933,21 @@ impl Project {
|
|||
}
|
||||
|
||||
self.buffer_store.update(cx, |buffer_store, cx| {
|
||||
buffer_store.open_buffer(path.into(), 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)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -3937,14 +3951,25 @@ 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| {
|
||||
this.open_buffer(
|
||||
ProjectPath {
|
||||
worktree_id,
|
||||
path: PathBuf::from(envelope.payload.path).into(),
|
||||
},
|
||||
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,
|
||||
)
|
||||
}
|
||||
})?;
|
||||
|
||||
let buffer = open_buffer.await?;
|
||||
|
@ -4073,12 +4098,10 @@ impl Project {
|
|||
.with_context(|| format!("creating commit message file {commit_message_file:?}"))?;
|
||||
|
||||
let (worktree, relative_path) = this
|
||||
.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)
|
||||
})
|
||||
.update(&mut cx, |project, cx| {
|
||||
project.worktree_store.update(cx, |worktree_store, cx| {
|
||||
worktree_store.find_or_create_worktree(&commit_message_file, false, cx)
|
||||
})
|
||||
})?
|
||||
.await
|
||||
.with_context(|| {
|
||||
|
@ -4086,18 +4109,17 @@ impl Project {
|
|||
})?;
|
||||
|
||||
let buffer = this
|
||||
.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,
|
||||
)
|
||||
})
|
||||
.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,
|
||||
)
|
||||
})
|
||||
})
|
||||
.with_context(|| {
|
||||
format!("opening buffer for commit message file {commit_message_file:?}")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue