Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/git_ui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ schemars.workspace = true
serde.workspace = true
serde_json.workspace = true
settings.workspace = true
smallvec.workspace = true
smol.workspace = true
strum.workspace = true
telemetry.workspace = true
Expand Down
38 changes: 29 additions & 9 deletions crates/git_ui/src/git_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ use project::{
use prompt_store::{BuiltInPrompt, PromptId, PromptStore, RULES_FILE_NAMES};
use serde::{Deserialize, Serialize};
use settings::{Settings, SettingsStore, StatusStyle};
use smallvec::SmallVec;
use std::future::Future;
use std::ops::Range;
use std::path::Path;
Expand Down Expand Up @@ -290,6 +291,15 @@ impl GitListEntry {
_ => None,
}
}

/// Returns the tree indentation depth for this entry.
fn depth(&self) -> usize {
match self {
GitListEntry::Directory(dir) => dir.depth,
GitListEntry::TreeStatus(status) => status.depth,
_ => 0,
}
}
}

enum GitPanelViewMode {
Expand Down Expand Up @@ -3806,6 +3816,24 @@ impl GitPanel {
self.has_staged_changes()
}

/// Computes tree indentation depths for visible entries in the given range.
/// Used by indent guides to render vertical connector lines in tree view.
fn compute_visible_depths(&self, range: Range<usize>) -> SmallVec<[usize; 64]> {
let GitPanelViewMode::Tree(state) = &self.view_mode else {
return SmallVec::new();
};

range
.map(|ix| {
state
.logical_indices
.get(ix)
.and_then(|&entry_ix| self.entries.get(entry_ix))
.map_or(0, |entry| entry.depth())
})
.collect()
}

fn status_width_estimate(
tree_view: bool,
entry: &GitStatusEntry,
Expand Down Expand Up @@ -4683,15 +4711,7 @@ impl GitPanel {
.with_compute_indents_fn(
cx.entity(),
|this, range, _window, _cx| {
range
.map(|ix| match this.entries.get(ix) {
Some(GitListEntry::Directory(dir)) => dir.depth,
Some(GitListEntry::TreeStatus(status)) => {
status.depth
}
_ => 0,
})
.collect()
this.compute_visible_depths(range)
},
)
.with_render_fn(cx.entity(), |_, params, _, _| {
Expand Down