Rework shared commit editors (#24274)
Rework of https://github.com/zed-industries/zed/pull/24130
Uses
1033c0b57e
`COMMIT_EDITMSG` language-related definitions (thanks @d1y )
Instead of using real `.git/COMMIT_EDITMSG` file, create a buffer
without FS representation, stored in the `Repository` and shared the
regular way via the `BufferStore`.
Adds a knowledge of what `Git Commit` language is, and uses it in the
buffers which are rendered in the git panel.
Release Notes:
- N/A
---------
Co-authored-by: Conrad Irwin <conrad@zed.dev>
Co-authored-by: d1y <chenhonzhou@gmail.com>
Co-authored-by: Smit <smit@zed.dev>
This commit is contained in:
parent
da4bad3a55
commit
868e3f75b2
17 changed files with 428 additions and 372 deletions
|
@ -4,7 +4,7 @@ use gpui::{
|
|||
};
|
||||
use picker::{Picker, PickerDelegate};
|
||||
use project::{
|
||||
git::{GitState, RepositoryHandle},
|
||||
git::{GitState, Repository},
|
||||
Project,
|
||||
};
|
||||
use std::sync::Arc;
|
||||
|
@ -117,13 +117,13 @@ impl<T: PopoverTrigger> RenderOnce for RepositorySelectorPopoverMenu<T> {
|
|||
pub struct RepositorySelectorDelegate {
|
||||
project: WeakEntity<Project>,
|
||||
repository_selector: WeakEntity<RepositorySelector>,
|
||||
repository_entries: Vec<RepositoryHandle>,
|
||||
filtered_repositories: Vec<RepositoryHandle>,
|
||||
repository_entries: Vec<Entity<Repository>>,
|
||||
filtered_repositories: Vec<Entity<Repository>>,
|
||||
selected_index: usize,
|
||||
}
|
||||
|
||||
impl RepositorySelectorDelegate {
|
||||
pub fn update_repository_entries(&mut self, all_repositories: Vec<RepositoryHandle>) {
|
||||
pub fn update_repository_entries(&mut self, all_repositories: Vec<Entity<Repository>>) {
|
||||
self.repository_entries = all_repositories.clone();
|
||||
self.filtered_repositories = all_repositories;
|
||||
self.selected_index = 0;
|
||||
|
@ -194,7 +194,7 @@ impl PickerDelegate for RepositorySelectorDelegate {
|
|||
let Some(selected_repo) = self.filtered_repositories.get(self.selected_index) else {
|
||||
return;
|
||||
};
|
||||
selected_repo.activate(cx);
|
||||
selected_repo.update(cx, |selected_repo, cx| selected_repo.activate(cx));
|
||||
self.dismissed(window, cx);
|
||||
}
|
||||
|
||||
|
@ -222,7 +222,7 @@ impl PickerDelegate for RepositorySelectorDelegate {
|
|||
) -> Option<Self::ListItem> {
|
||||
let project = self.project.upgrade()?;
|
||||
let repo_info = self.filtered_repositories.get(ix)?;
|
||||
let display_name = repo_info.display_name(project.read(cx), cx);
|
||||
let display_name = repo_info.read(cx).display_name(project.read(cx), cx);
|
||||
// TODO: Implement repository item rendering
|
||||
Some(
|
||||
ListItem::new(ix)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue