mirror of
https://github.com/denisidoro/navi
synced 2024-11-24 12:33:05 +00:00
Widget: fix replacements in case of multiple occurrences
This commit is contained in:
parent
3abd3dad6e
commit
9396fd539c
3 changed files with 12 additions and 4 deletions
|
@ -29,6 +29,12 @@ navi --tldr "<query>"
|
|||
navi --cheatsh "<query>"
|
||||
|
||||
|
||||
% widget
|
||||
|
||||
# Load shell widget
|
||||
shell="$(basename $SHELL)"; eval "$(navi widget $shell)"
|
||||
|
||||
|
||||
% help
|
||||
|
||||
# Read command-line help text
|
||||
|
|
|
@ -12,11 +12,12 @@ _navi_widget() {
|
|||
if [ -z "${last_command}" ]; then
|
||||
local -r output="$(_navi_call --print)"
|
||||
else
|
||||
local -r find="$last_command"
|
||||
local -r find="${last_command}_NAVIEND"
|
||||
local -r replacement="$(_navi_call --print --query "$last_command")"
|
||||
local output="$input"
|
||||
if [ -n "$replacement" ]; then
|
||||
output="${input//$find/$replacement}"
|
||||
output="${input}_NAVIEND"
|
||||
output="${output//$find/$replacement}"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ _navi_call() {
|
|||
_navi_widget() {
|
||||
local -r input="${LBUFFER}"
|
||||
local -r last_command="$(echo "${input}" | navi fn widget::last_command)"
|
||||
local find="$last_command"
|
||||
local replacement="$last_command"
|
||||
|
||||
if [ -z "$last_command" ]; then
|
||||
|
@ -20,7 +19,9 @@ _navi_widget() {
|
|||
fi
|
||||
|
||||
if [ -n "$replacement" ]; then
|
||||
previous_output="${input//$find/$replacement}"
|
||||
local -r find="${last_command}_NAVIEND"
|
||||
previous_output="${input}_NAVIEND"
|
||||
previous_output="${previous_output//$find/$replacement}"
|
||||
else
|
||||
previous_output="$input"
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue