mirror of
https://github.com/denisidoro/navi
synced 2024-11-21 19:13:07 +00:00
Merge pull request #670 from cherryblossom000/patch-1
Update legacy syntax from Elvish widget
This commit is contained in:
commit
153d081d40
1 changed files with 13 additions and 15 deletions
|
@ -1,31 +1,29 @@
|
||||||
use str
|
use str
|
||||||
|
|
||||||
fn call-navi []{
|
fn call-navi {
|
||||||
if (eq $edit:current-command '') {
|
if (eq $edit:current-command '') {
|
||||||
answer = (navi --print)
|
var answer = (navi --print)
|
||||||
edit:replace-input $answer
|
edit:replace-input $answer
|
||||||
} elif (not (str:contains-any $edit:current-command '|')) {
|
} 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 '') {
|
if (not-eq $answer '') {
|
||||||
edit:replace-input $answer
|
edit:replace-input $answer
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
cmds = [(str:split '|' $edit:current-command)]
|
var @cmds query = (str:split '|' $edit:current-command)
|
||||||
qty = (- (count $cmds) 1)
|
var answer = (
|
||||||
query = (all $cmds | drop $qty)
|
if (eq $query '') {
|
||||||
cmds = [(all $cmds | take $qty)]
|
navi --print
|
||||||
answer = ''
|
} else {
|
||||||
if (eq $query '') {
|
navi --print --query $query
|
||||||
answer = (navi --print)
|
}
|
||||||
} else {
|
)
|
||||||
answer = (navi --print --query $query)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (not-eq $answer '') {
|
if (not-eq $answer '') {
|
||||||
cmds = [$@cmds $answer]
|
set cmds = [$@cmds $answer]
|
||||||
edit:replace-input (str:join '| ' $cmds)
|
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 }
|
||||||
|
|
Loading…
Reference in a new issue