diff options
author | Denis Isidoro <denisidoro@users.noreply.github.com> | 2020-04-13 14:27:05 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-13 14:27:05 -0300 |
commit | 4853a6718cbc9c256c22118243a7c5390b46b815 (patch) | |
tree | 385b73c414345f6345c59989ede9b5c2baf715c2 | |
parent | 3188a767598f84b65906428678c28dfdac2741c0 (diff) |
Disable preview-window for variable suggestions (#343)v2.5.1
Fixes #338
Reopens #320
-rw-r--r-- | src/flows/core.rs | 30 | ||||
-rw-r--r-- | tests/cheats/more_cases.cheat | 8 |
2 files changed, 23 insertions, 15 deletions
diff --git a/src/flows/core.rs b/src/flows/core.rs index 951c716..a799054 100644 --- a/src/flows/core.rs +++ b/src/flows/core.rs @@ -71,12 +71,20 @@ fn extract_from_selections(raw_snippet: &str, contains_key: bool) -> (&str, &str (key, tags, snippet) } +/* fn gen_opts_preview(snippet: &str, variable_name: &str) -> Option<String> { + Some(format!( + r#"query="{{}}"; [[ "${{#query:-}}" -lt 3 ]] && query="{{q}}"; query="${{query:1:${{#query}}-2}}"; query="$(echo "$query" | sed 's|/|\\/|g')"; echo "{}" | sed "s/<{}>/${{query}}/g" || echo 'Unable to generate command preview'"#, + snippet.replace('"', "\\\""), + variable_name + )) +} */ + fn prompt_with_suggestions( variable_name: &str, config: &Config, suggestion: &Suggestion, values: &HashMap<String, String>, - snippet: String, + _snippet: String, ) -> Result<String, Error> { let mut vars_cmd = String::from(""); for (key, value) in values.iter() { @@ -100,17 +108,13 @@ fn prompt_with_suggestions( ) .context("Suggestions are invalid utf8")?; - let mut opts = suggestion_opts.clone().unwrap_or_default(); - if opts.preview.is_none() { - opts.preview = Some(format!( - "echo '{}' | sed 's/<{}>/{{}}/g'", - snippet.replace('\'', "\""), - variable_name - )); + let opts = suggestion_opts.clone().unwrap_or_default(); + /* if opts.preview.is_none() { + opts.preview = gen_opts_preview(&snippet, &variable_name); } if opts.preview_window.is_none() { opts.preview_window = Some("up:1".to_string()); - } + } */ let opts = FinderOpts { autoselect: !config.no_autoselect, overrides: config.fzf_overrides_var.clone(), @@ -134,17 +138,13 @@ fn prompt_with_suggestions( fn prompt_without_suggestions( variable_name: &str, config: &Config, - snippet: String, + _snippet: String, ) -> Result<String, Error> { let opts = FinderOpts { autoselect: false, prompt: Some(display::variable_prompt(variable_name)), suggestion_type: SuggestionType::Disabled, - preview: Some(format!( - "echo '{}' | sed 's/<{}>/{{}}/g'", - snippet.replace('\'', "\""), - variable_name - )), + // preview: gen_opts_preview(&snippet, &variable_name), preview_window: Some("up:1".to_string()), ..Default::default() }; diff --git a/tests/cheats/more_cases.cheat b/tests/cheats/more_cases.cheat index 6ec034b..b1a1872 100644 --- a/tests/cheats/more_cases.cheat +++ b/tests/cheats/more_cases.cheat @@ -50,6 +50,14 @@ echo description space # echo description blank +# x +echo description one character + +# Concatenate pdf files +files=($(echo "<files>")) +echo pdftk "${files[@]:-}" cat output <pdf_output> + +$ files: echo 'file1.pdf file2.pdf file3.pdf' | tr ' ' '\n' --- --multi --overrides '--tac' $ x: echo '1 2 3' | tr ' ' '\n' $ y: echo 'a b c' | tr ' ' '\n' $ z: echo 'foo bar' | tr ' ' '\n' |