Some cleanup

pull/585/head
Arijit Basu 1 year ago
parent f03dfcc759
commit e62cba07f2

@ -1150,7 +1150,7 @@ Example:
- Lua: `"SearchRegexUnorderedFromInput"`
- YAML: `SearchRegexUnorderedFromInput`
#### CycleSearchAlgorithm
#### ToggleSearchAlgorithm
Cycles through different search algorithms, without changing the input
buffer
@ -1161,34 +1161,34 @@ Example:
- Lua: `"CycleSearchAlgorithm"`
- YAML: `CycleSearchAlgorithm`
#### EnableRankedSearch
#### EnableSearchOrder
Enables ranked search without changing the input buffer.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
Example:
- Lua: `"EnableRankedSearch"`
- YAML: `EnableRankedSearch`
- Lua: `"EnableOrderedSearch"`
- YAML: `EnableSearchOrder`
#### DisableRankedSearch
#### DisableSearchOrder
Disabled ranked search without changing the input buffer.
You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
Example:
- Lua: `"DisableRankedSearch"`
- YAML: `DisableRankedSearch`
- Lua: `"DisableSearchOrder"`
- YAML: `DisableSearchOrder`
#### ToggleRankedSearch
#### ToggleSearchOrder
Toggles ranked search without changing the input buffer.
Example:
- Lua: `"ToggleRankedSearch"`
- YAML: `ToggleRankedSearch`
- Lua: `"ToggleSearchOrder"`
- YAML: `ToggleSearchOrder`
#### AcceptSearch

@ -549,10 +549,10 @@ impl App {
SearchRegexUnorderedFromInput => {
self.search_from_input_with(SearchAlgorithm::Regex, true)
}
EnableRankedSearch => self.enable_search_order(),
DisableRankedSearch => self.disable_search_order(),
ToggleRankedSearch => self.toggle_search_order(),
CycleSearchAlgorithm => self.toggle_search_algorithm(),
EnableSearchOrder => self.enable_search_order(),
DisableSearchOrder => self.disable_search_order(),
ToggleSearchOrder => self.toggle_search_order(),
ToggleSearchAlgorithm => self.toggle_search_algorithm(),
AcceptSearch => self.accept_search(),
CancelSearch => self.cancel_search(),
EnableMouse => self.enable_mouse(),

@ -27,12 +27,13 @@ pub fn explore(parent: &PathBuf, config: &ExplorerConfig) -> Result<Vec<Node>> {
nodes.collect()
};
let ignore_sort = config
let is_ordered_search = config
.searcher
.as_ref()
.map(|s| s.unordered)
.map(|s| !s.unordered)
.unwrap_or(false);
if !ignore_sort {
if !is_ordered_search {
nodes.sort_by(|a, b| config.sort(a, b));
}

@ -2138,16 +2138,16 @@ xplr.config.modes.builtin.search = {
},
},
["ctrl-z"] = {
help = "toggle ranking",
help = "toggle ordering",
messages = {
"ToggleRankedSearch",
"ToggleSearchOrder",
"ExplorePwdAsync",
},
},
["ctrl-a"] = {
help = "cycle search algorithm",
help = "toggle search algorithm",
messages = {
"CycleSearchAlgorithm",
"ToggleSearchAlgorithm",
"ExplorePwdAsync",
},
},
@ -2166,9 +2166,9 @@ xplr.config.modes.builtin.search = {
},
},
["ctrl-s"] = {
help = "sort (disables ranking)",
help = "sort (no search order)",
messages = {
"DisableRankedSearch",
"DisableSearchOrder",
"ExplorePwdAsync",
{ SwitchModeBuiltinKeepingInputBuffer = "sort" },
},

@ -1042,33 +1042,33 @@ pub enum ExternalMsg {
///
/// - Lua: `"CycleSearchAlgorithm"`
/// - YAML: `CycleSearchAlgorithm`
CycleSearchAlgorithm,
ToggleSearchAlgorithm,
/// Enables ranked search without changing the input buffer.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
///
/// Example:
///
/// - Lua: `"EnableRankedSearch"`
/// - YAML: `EnableRankedSearch`
EnableRankedSearch,
/// - Lua: `"EnableOrderedSearch"`
/// - YAML: `EnableSearchOrder`
EnableSearchOrder,
/// Disabled ranked search without changing the input buffer.
/// You need to call `ExplorePwd` or `ExplorePwdAsync` explicitely.
///
/// Example:
///
/// - Lua: `"DisableRankedSearch"`
/// - YAML: `DisableRankedSearch`
DisableRankedSearch,
/// - Lua: `"DisableSearchOrder"`
/// - YAML: `DisableSearchOrder`
DisableSearchOrder,
/// Toggles ranked search without changing the input buffer.
///
/// Example:
///
/// - Lua: `"ToggleRankedSearch"`
/// - YAML: `ToggleRankedSearch`
ToggleRankedSearch,
/// - Lua: `"ToggleSearchOrder"`
/// - YAML: `ToggleSearchOrder`
ToggleSearchOrder,
/// Accepts the search by keeping the latest focus while in search mode.
/// Automatically calls `ExplorePwd`.

@ -1034,6 +1034,8 @@ fn draw_sort_n_filter<B: Backend>(
.to_owned()
.extend(&ui.search_direction_identifiers.unordered);
let is_ordered_search = search.as_ref().map(|s| !s.unordered).unwrap_or(false);
let mut spans = filter_by
.iter()
.map(|f| {
@ -1098,11 +1100,7 @@ fn draw_sort_n_filter<B: Backend>(
})
.unwrap_or((Span::raw("s"), Span::raw("")))
})
.take(if search.map(|s| s.unordered).unwrap_or(false) {
sort_by.len()
} else {
0
}),
.take(if !is_ordered_search { sort_by.len() } else { 0 }),
)
.zip(std::iter::repeat(Span::styled(
ui.separator.format.to_owned().unwrap_or_default(),

Loading…
Cancel
Save