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 May 4, 2024
2 parents c7a1886 + 7feece5 commit a626209
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
### next
- `-{flags}` verb lets you change the state the same way you do it at start, eg `:-sd` to show sizes and dates
- calling `:focus` on the tree root now goes up the tree (experimental)

### v1.37.0 - 2024-04-28
<a name="v1.37.0"></a>
Expand Down
29 changes: 20 additions & 9 deletions src/browser/browser_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,15 +347,26 @@ impl PanelState for BrowserState {
CmdResult::PopState
}
}
Internal::focus => internal_focus::on_internal(
internal_exec,
input_invocation,
trigger_type,
&self.displayed_tree().selected_line().path,
self.displayed_tree().options.clone(),
app_state,
cc,
),
Internal::focus => {
let tree = self.displayed_tree();
let mut path = &tree.selected_line().path;
let parent;
if tree.is_root_selected() {
if let Some(parent_path) = path.parent() {
parent = parent_path.to_path_buf();
path = &parent;
}
}
internal_focus::on_internal(
internal_exec,
input_invocation,
trigger_type,
path,
tree.options.clone(),
app_state,
cc,
)
}
Internal::select => internal_select::on_internal(
internal_exec,
input_invocation,
Expand Down
3 changes: 3 additions & 0 deletions src/tree/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,9 @@ impl Tree {
pub fn root(&self) -> &PathBuf {
&self.lines[0].path
}
pub fn is_root_selected(&self) -> bool {
self.selection == 0
}
/// select the line with the best matching score
pub fn try_select_best_match(&mut self) {
let mut best_score = 0;
Expand Down

0 comments on commit a626209

Please sign in to comment.