Merge pull request #670 from cherryblossom000/patch-1

Update legacy syntax from Elvish widget
This commit is contained in:
Denis Isidoro 2022-01-14 21:35:28 -03:00 committed by GitHub
commit 153d081d40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 = ''
var @cmds query = (str:split '|' $edit:current-command)
var answer = (
if (eq $query '') {
answer = (navi --print)
navi --print
} else {
answer = (navi --print --query $query)
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 }
set edit:insert:binding[Alt-h] = { call-navi >/dev/tty 2>&1 }