Add initial project panel settings

This commit is contained in:
Mikayla Maki 2023-05-22 20:23:07 -07:00
parent 54c04a6618
commit 7be8dead07
No known key found for this signature in database
5 changed files with 49 additions and 1 deletions

View file

@ -1,3 +1,5 @@
mod project_panel_settings;
use context_menu::{ContextMenu, ContextMenuItem};
use drag_and_drop::{DragAndDrop, Draggable};
use editor::{Cancel, Editor};
@ -20,6 +22,7 @@ use project::{
repository::GitFileStatus, Entry, EntryKind, Project, ProjectEntryId, ProjectPath, Worktree,
WorktreeId,
};
use project_panel_settings::ProjectPanelSettings;
use std::{
cmp::Ordering,
collections::{hash_map, HashMap},
@ -111,6 +114,7 @@ actions!(
);
pub fn init(cx: &mut AppContext) {
settings::register::<ProjectPanelSettings>(cx);
cx.add_action(ProjectPanel::expand_selected_entry);
cx.add_action(ProjectPanel::collapse_selected_entry);
cx.add_action(ProjectPanel::select_prev);
@ -1000,6 +1004,7 @@ impl ProjectPanel {
}
let end_ix = range.end.min(ix + visible_worktree_entries.len());
let git_status_setting = settings::get::<ProjectPanelSettings>(cx).git_status;
if let Some(worktree) = self.project.read(cx).worktree_for_id(*worktree_id, cx) {
let snapshot = worktree.read(cx).snapshot();
let root_name = OsStr::new(snapshot.root_name());
@ -1013,7 +1018,7 @@ impl ProjectPanel {
for (entry, repo) in
snapshot.entries_with_repositories(visible_worktree_entries[entry_range].iter())
{
let status = (entry.path.parent().is_some() && !entry.is_ignored)
let status = (git_status_setting && entry.path.parent().is_some() && !entry.is_ignored)
.then(|| repo.and_then(|repo| repo.status_for_path(&snapshot, &entry.path)))
.flatten();