From c082c09935a2b8e49fc381bbc66c755ff700147d Mon Sep 17 00:00:00 2001 From: cherryblossom000 <31467609+cherryblossom000@users.noreply.github.com> Date: Thu, 13 Jan 2022 21:34:55 +1100 Subject: [PATCH] Update legacy syntax from Elvish widget This commit updates the legacy assignment and lambda syntax from the Elvish widget so it works on v0.17 without deprecation errors. This commit also refactors some of the code so it's cleaner. --- shell/navi.plugin.elv | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/shell/navi.plugin.elv b/shell/navi.plugin.elv index f1aa49c..8229dab 100644 --- a/shell/navi.plugin.elv +++ b/shell/navi.plugin.elv @@ -1,31 +1,29 @@ use str -fn call-navi []{ +fn call-navi { if (eq $edit:current-command '') { - answer = (navi --print) + var answer = (navi --print) edit:replace-input $answer } elif (not (str:contains-any $edit:current-command '|')) { - answer = (navi --print --query $edit:current-command) + var answer = (navi --print --query $edit:current-command) if (not-eq $answer '') { edit:replace-input $answer } } else { - cmds = [(str:split '|' $edit:current-command)] - qty = (- (count $cmds) 1) - query = (all $cmds | drop $qty) - cmds = [(all $cmds | take $qty)] - answer = '' - if (eq $query '') { - answer = (navi --print) - } else { - answer = (navi --print --query $query) - } + var @cmds query = (str:split '|' $edit:current-command) + var answer = ( + if (eq $query '') { + navi --print + } else { + navi --print --query $query + } + ) if (not-eq $answer '') { - cmds = [$@cmds $answer] + set cmds = [$@cmds $answer] edit:replace-input (str:join '| ' $cmds) } } } -edit:insert:binding[Alt-h] = []{ call-navi >/dev/tty 2>&1 } \ No newline at end of file +set edit:insert:binding[Alt-h] = { call-navi >/dev/tty 2>&1 }