Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
Canop committed Mar 9, 2024
2 parents b76b484 + 36abe9c commit eb4d97a
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
33 changes: 28 additions & 5 deletions src/browser/browser_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ enum BrowserTask {
pattern: InputPattern,
total: bool,
},
StageAll(InputPattern),
StageAll {
pattern: InputPattern,
file_type_condition: FileTypeCondition,
},
}

impl BrowserState {
Expand Down Expand Up @@ -215,7 +218,7 @@ impl PanelState for BrowserState {
self
.pending_task.as_ref().map(|task| match task {
BrowserTask::Search{ .. } => "searching",
BrowserTask::StageAll(_) => "staging",
BrowserTask::StageAll{ .. } => "staging",
})
}
}
Expand Down Expand Up @@ -526,9 +529,25 @@ impl PanelState for BrowserState {
CmdResult::error("No selected line")
}
}
Internal::stage_all_directories => {
let pattern = self.displayed_tree().options.pattern.clone();
let file_type_condition = FileTypeCondition::Directory;
self.pending_task = Some(BrowserTask::StageAll{pattern, file_type_condition});
if cc.app.stage_panel.is_none() {
let stage_options = self.tree.options.without_pattern();
CmdResult::NewPanel {
state: Box::new(StageState::new(app_state, stage_options, con)),
purpose: PanelPurpose::None,
direction: HDir::Right,
}
} else {
CmdResult::Keep
}
}
Internal::stage_all_files => {
let pattern = self.displayed_tree().options.pattern.clone();
self.pending_task = Some(BrowserTask::StageAll(pattern));
let file_type_condition = FileTypeCondition::File;
self.pending_task = Some(BrowserTask::StageAll{pattern, file_type_condition});
if cc.app.stage_panel.is_none() {
let stage_options = self.tree.options.without_pattern();
CmdResult::NewPanel {
Expand Down Expand Up @@ -684,7 +703,8 @@ impl PanelState for BrowserState {
self.filtered_tree = Some(ft);
}
}
BrowserTask::StageAll(pattern) => {
BrowserTask::StageAll { pattern, file_type_condition } => {
info!("stage all pattern: {:?}", pattern);
let tree = self.displayed_tree();
let root = tree.root().clone();
let mut options = tree.options.clone();
Expand All @@ -697,7 +717,10 @@ impl PanelState for BrowserState {
time!(builder.build_paths(
total_search,
dam,
|line| line.file_type.is_file() || line.file_type.is_symlink(),
|line| {
info!("??staging {:?}", &line.path);
file_type_condition.accepts_path(&line.path)
}
))
})?;
for path in paths.drain(..) {
Expand Down
4 changes: 3 additions & 1 deletion src/tree_build/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,9 @@ impl<'c> TreeBuilder<'c> {
.map(|mut blines_ids| {
blines_ids
.drain(..)
.filter(|&bid| filter(&self.blines[bid]))
.filter(|&bid| {
self.blines[bid].direct_match && filter(&self.blines[bid])
})
.map(|id| self.blines[id].path.clone())
.collect()
})
Expand Down
1 change: 1 addition & 0 deletions src/verb/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ Internals! {
sort_by_type_dirs_first: "sort by type, dirs first" false,
sort_by_type_dirs_last: "sort by type, dirs last" false,
stage: "add selection to staging area" true,
stage_all_directories: "stage all matching directories" true,
stage_all_files: "stage all matching files" true,
start_end_panel: "either open or close an additional panel" true,
toggle_counts: "toggle showing number of files in directories" false,
Expand Down
1 change: 1 addition & 0 deletions src/verb/verb_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ impl VerbStore {
.with_key(key!('+'));
self.add_internal(unstage)
.with_key(key!('-'));
self.add_internal(stage_all_directories);
self.add_internal(stage_all_files)
.with_key(key!(ctrl-a));
self.add_internal(toggle_stage)
Expand Down
1 change: 1 addition & 0 deletions website/docs/conf_verbs.md
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ invocation | default key | default shortcut | behavior / details
:sort_by_type_dirs_first | - | - | sort by type, dirs first
:sort_by_type_dirs_last | - | - | sort by type, dirs last
:stage | <kbd>+</kbd> | - | add selection to staging area
:stage_all_directories | - | - | add all directories verifying the pattern to the staging area
:stage_all_files | <kbd>ctrl</kbd><kbd>a</kbd> | - | add all files verifying the pattern to the staging area
:start_end_panel | - | - | either open or close an additional panel
:toggle_counts | - | - | toggle display of total counts of files per directory
Expand Down

0 comments on commit eb4d97a

Please sign in to comment.