Git · CommitList, FileHistory, BlameView draw only rows in view, rows are stops with list semantics; CommitList loads more near its end; CommitInput words read i18n

This commit is contained in:
ZacharyZhang-NY committed 2026-10-07 01:16:54 -04:00
1 parent 7b807a9478
commit 51d2aea02e
9 files changed
+472 -221

No files matched your search

+11 -4
View File
@@ -37,7 +37,14 @@ pub fn blame(window: &mut Window, cx: &mut App) -> impl IntoElement + use<> {
];
let history_rows: Vec<_> = history()
.into_iter()
.zip([(12, 4), (3, 3), (9, 1), (18, 0), (2, 1), (40, 0)])
.zip([
Some((12, 4)),
Some((3, 3)),
Some((9, 1)),
Some((18, 0)),
None,
Some((40, 0)),
])
.collect();
let (pick, select) = (said.clone(), said.clone());
section(
@@ -46,7 +53,7 @@ pub fn blame(window: &mut Window, cx: &mut App) -> impl IntoElement + use<> {
cx,
)
.child(
div().w(px(840.)).child(
div().w(px(840.)).h(px(240.)).child(
BlameView::new("git-blame", CODE, [0, 1, 1, 1, 0, 0, 2, 2, 0, 0], blames)
.current(2)
.on_commit(move |commit, _, cx| set(&pick, Some(format!("Picked {}.", &commit[..7]).into()), cx)),
@@ -54,8 +61,8 @@ pub fn blame(window: &mut Window, cx: &mut App) -> impl IntoElement + use<> {
)
.children(told.map(Caption::new))
.child(
div().w(px(520.)).child(
FileHistory::new("git-file-history", history_rows)
div().w(px(520.)).h(px(360.)).child(
FileHistory::new("git-file-history", std::rc::Rc::new(history_rows))
.selected(history()[1].id.clone())
.on_pick(move |commit, _, cx| set(&select, Some(format!("Opened {}.", &commit[..7]).into()), cx)),
),
+21 -4
View File
@@ -3,11 +3,13 @@ use ely_gpui_component::{
forms::TextInput,
git::{
Branch, BranchList, BranchSelector, ChangeAction, Changed, ChangesList, Commit,
CommitInput, CommitList, GitTag, Stash, StashAction, StashList, TagList,
CommitInput, CommitList, GitTag, GraphRow, Stash, StashAction, StashList, TagList, lanes,
},
lists::GitStatus,
typography::Caption,
};
use std::rc::Rc;
use gpui::{App, Entity, IntoElement, ParentElement, SharedString, Styled, Window, div, px};
use crate::{
@@ -210,6 +212,21 @@ pub(super) fn history() -> Vec<Commit> {
]
}
/// The sample history's lanes.
fn graph() -> Vec<GraphRow> {
let commits = history();
let parents: Vec<Vec<&str>> = commits
.iter()
.map(|commit| commit.parents.iter().map(|id| id.as_ref()).collect())
.collect();
lanes(
commits
.iter()
.zip(&parents)
.map(|(commit, parents)| (commit.id.as_ref(), parents.as_slice())),
)
}
pub fn commits(window: &mut Window, cx: &mut App) -> impl IntoElement + use<> {
let picked = keep("git-picked", || history()[0].id.clone(), window, cx);
let now = picked.read(cx).clone();
@@ -220,9 +237,9 @@ pub fn commits(window: &mut Window, cx: &mut App) -> impl IntoElement + use<> {
cx,
)
.child(
div().w(px(840.)).child(
CommitList::new("git-graph", history())
.graph()
div().w(px(840.)).h(px(320.)).child(
CommitList::new("git-graph", Rc::new(history()))
.graph(Rc::new(graph()))
.selected(now)
.on_pick(move |id, _, cx| set(&pick, id.clone(), cx)),
),