Git: clear CI's lints; a row's drawn parts gather in Entry, the history's tuple is Counted, picking tests sit under tests/

This commit is contained in:
ZacharyZhang-NY committed 2026-10-07 07:39:01 -04:00
1 parent 179ea8e276
commit 083ef85696
6 files changed
+56 -45

No files matched your search

+4 -5
View File
@@ -13,22 +13,21 @@ use crate::{
}; };
type OnPick = Rc<dyn Fn(&SharedString, &mut Window, &mut App)>; type OnPick = Rc<dyn Fn(&SharedString, &mut Window, &mut App)>;
/// A commit with lines added and removed, if counted.
pub type Counted = (Commit, Option<(usize, usize)>);
/// A file's commits newest first; draws rows in view. /// A file's commits newest first; draws rows in view.
#[derive(IntoElement)] #[derive(IntoElement)]
pub struct FileHistory { pub struct FileHistory {
id: ElementId, id: ElementId,
commits: Rc<Vec<(Commit, Option<(usize, usize)>)>>, commits: Rc<Vec<Counted>>,
selected: Option<SharedString>, selected: Option<SharedString>,
on_pick: Option<OnPick>, on_pick: Option<OnPick>,
} }
impl FileHistory { impl FileHistory {
/// Each commit with lines added and removed, if counted. /// Each commit with lines added and removed, if counted.
pub fn new( pub fn new(id: impl Into<ElementId>, commits: Rc<Vec<Counted>>) -> Self {
id: impl Into<ElementId>,
commits: Rc<Vec<(Commit, Option<(usize, usize)>)>>,
) -> Self {
Self { Self {
id: id.into(), id: id.into(),
commits, commits,
-2
View File
@@ -7,8 +7,6 @@ mod graph;
mod history; mod history;
mod merge; mod merge;
mod merging; mod merging;
#[cfg(all(test, feature = "test-support"))]
mod picking;
mod refs; mod refs;
mod review; mod review;
mod rows; mod rows;
+27 -19
View File
@@ -204,17 +204,23 @@ pub(super) struct Pick {
pub run: Run, pub run: Run,
} }
/// A row's name, detail, trailing words and hover actions. /// A row's icon, name, detail, trailing words and hover actions.
pub(super) fn listed( pub(super) struct Entry {
id: ElementId, pub icon: IconName,
icon: IconName, pub name: AnyElement,
name: AnyElement, pub detail: SharedString,
detail: SharedString, pub trailing: Vec<SharedString>,
trailing: Vec<SharedString>, pub actions: Vec<AnyElement>,
actions: Vec<AnyElement>, }
pick: Option<Pick>,
cx: &App, pub(super) fn listed(id: ElementId, entry: Entry, pick: Option<Pick>, cx: &App) -> AnyElement {
) -> AnyElement { let Entry {
icon,
name,
detail,
trailing,
actions,
} = entry;
let theme = cx.theme(); let theme = cx.theme();
let colors = theme.colors.clone(); let colors = theme.colors.clone();
div() div()
@@ -406,15 +412,17 @@ impl RenderOnce for BranchList {
.collect(); .collect();
listed( listed(
(self.id.clone(), format!("branch-{}", branch.name)).into(), (self.id.clone(), format!("branch-{}", branch.name)).into(),
if branch.current { Entry {
IconName::Check icon: if branch.current {
} else { IconName::Check
IconName::GitBranch } else {
IconName::GitBranch
},
name,
detail: branch.subject.clone(),
trailing,
actions,
}, },
name,
branch.subject.clone(),
trailing,
actions,
bind(&self.on_pick).map(|run| Pick { bind(&self.on_pick).map(|run| Pick {
spoken: branch.name.clone(), spoken: branch.name.clone(),
selected: self.selected.as_ref() == Some(&branch.name), selected: self.selected.as_ref() == Some(&branch.name),
+22 -18
View File
@@ -5,7 +5,7 @@ use gpui::{
Window, div, Window, div,
}; };
use super::refs::{OnName, Pick, Run, action, listed}; use super::refs::{Entry, OnName, Pick, Run, action, listed};
use crate::{ use crate::{
i18n, i18n,
primitives::IconName, primitives::IconName,
@@ -70,14 +70,16 @@ impl RenderOnce for TagList {
let short: String = tag.commit.chars().take(7).collect(); let short: String = tag.commit.chars().take(7).collect();
listed( listed(
(self.id.clone(), format!("tag-{}", tag.name)).into(), (self.id.clone(), format!("tag-{}", tag.name)).into(),
IconName::Tag, Entry {
div() icon: IconName::Tag,
.text_color(colors.fg) name: div()
.child(tag.name.clone()) .text_color(colors.fg)
.into_any_element(), .child(tag.name.clone())
tag.message.clone().unwrap_or_default(), .into_any_element(),
vec![short.into(), tag.when.clone()], detail: tag.message.clone().unwrap_or_default(),
Vec::new(), trailing: vec![short.into(), tag.when.clone()],
actions: Vec::new(),
},
self.on_pick.clone().map(|pick| { self.on_pick.clone().map(|pick| {
let name = tag.name.clone(); let name = tag.name.clone();
Pick { Pick {
@@ -197,15 +199,17 @@ impl RenderOnce for StashList {
}); });
listed( listed(
(self.id.clone(), format!("stash-{ix}")).into(), (self.id.clone(), format!("stash-{ix}")).into(),
IconName::Archive, Entry {
div() icon: IconName::Archive,
.font_family(theme.mono_family.clone()) name: div()
.text_color(colors.fg) .font_family(theme.mono_family.clone())
.child(name) .text_color(colors.fg)
.into_any_element(), .child(name)
detail, .into_any_element(),
vec![stash.when.clone()], detail,
actions, trailing: vec![stash.when.clone()],
actions,
},
pick, pick,
cx, cx,
) )
@@ -4,6 +4,8 @@ use gpui::{
}; };
use super::DiffViewer; use super::DiffViewer;
mod picking;
use crate::{forms, primitives::FocusNext, theme::Theme}; use crate::{forms, primitives::FocusNext, theme::Theme};
/// A diff whose first stretch folds, and folds asked open. /// A diff whose first stretch folds, and folds asked open.
@@ -7,7 +7,7 @@ use gpui::{
TestAppContext, VisualTestContext, Window, div, px, TestAppContext, VisualTestContext, Window, div, px,
}; };
use super::{ use crate::git::{
Blame, BlameView, Branch, BranchList, Commit, CommitList, FileHistory, GitTag, Stash, Blame, BlameView, Branch, BranchList, Commit, CommitList, FileHistory, GitTag, Stash,
StashList, TagList, StashList, TagList,
}; };