mirror of
https://github.com/denisidoro/navi.git
synced 2026-07-28 20:41:02 +00:00
Allow variable suggestions to use preview window (#399)
This commit is contained in:
parent
04f037c865
commit
6808dccf5c
3 changed files with 18 additions and 5 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -172,7 +172,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
|
||||
[[package]]
|
||||
name = "navi"
|
||||
version = "2.11.0"
|
||||
version = "2.12.0"
|
||||
dependencies = [
|
||||
"anyhow 1.0.32 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"dirs 3.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
[package]
|
||||
name = "navi"
|
||||
version = "2.11.0"
|
||||
version = "2.12.0"
|
||||
authors = ["Denis Isidoro <denis_isidoro@live.com>"]
|
||||
edition = "2018"
|
||||
description = "An interactive cheatsheet tool for the command-line"
|
||||
|
|
|
|||
|
|
@ -59,6 +59,8 @@ fn prompt_finder(variable_name: &str, config: &Config, suggestion: Option<&Sugge
|
|||
env::remove_var(env_vars::PREVIEW_DELIMITER);
|
||||
env::remove_var(env_vars::PREVIEW_MAP);
|
||||
|
||||
let mut extra_preview = None;
|
||||
|
||||
let (suggestions, opts) = if let Some(s) = suggestion {
|
||||
let (suggestion_command, suggestion_opts) = s;
|
||||
|
||||
|
|
@ -72,6 +74,9 @@ fn prompt_finder(variable_name: &str, config: &Config, suggestion: Option<&Sugge
|
|||
if let Some(m) = &sopts.map {
|
||||
env::set_var(env_vars::PREVIEW_MAP, m);
|
||||
}
|
||||
if let Some(p) = &sopts.preview {
|
||||
extra_preview = Some(format!(";echo;{}", p));
|
||||
}
|
||||
}
|
||||
|
||||
let child = Command::new("bash")
|
||||
|
|
@ -99,13 +104,21 @@ NAVIEOF
|
|||
)" "$(cat <<NAVIEOF
|
||||
{{q}}
|
||||
NAVIEOF
|
||||
)" "{}""#,
|
||||
variable_name
|
||||
)" "{}"{}"#,
|
||||
variable_name,
|
||||
extra_preview.clone().unwrap_or_default()
|
||||
)),
|
||||
preview_window: Some(format!("up:{}", variable_count + 3)),
|
||||
..opts.clone().unwrap_or_default()
|
||||
};
|
||||
|
||||
if opts.preview_window.is_none() {
|
||||
opts.preview_window = Some(if extra_preview.is_none() {
|
||||
format!("up:{}", variable_count + 3)
|
||||
} else {
|
||||
"right:50%".to_string()
|
||||
});
|
||||
}
|
||||
|
||||
if suggestion.is_none() {
|
||||
opts.suggestion_type = SuggestionType::Disabled;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue