Merge pull request #2436 from ajeetdsouza/ajeet/elvish

Fix completions for Elvish shell
This commit is contained in:
Pavan Kumar Sunkara 2021-04-08 18:57:48 +05:30 committed by GitHub
commit 9be6db5999
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 12 deletions

View file

@ -22,16 +22,19 @@ impl Generator for Elvish {
let result = format!(
r#"
use builtin;
use str;
edit:completion:arg-completer[{bin_name}] = [@words]{{
fn spaces [n]{{
repeat $n ' ' | joins ''
builtin:repeat $n ' ' | str:join ''
}}
fn cand [text desc]{{
edit:complex-candidate $text &display-suffix=' '(spaces (- 14 (wcswidth $text)))$desc
}}
command = '{bin_name}'
for word $words[1:-1] {{
if (has-prefix $word '-') {{
for word $words[1..-1] {{
if (str:has-prefix $word '-') {{
break
}}
command = $command';'$word

View file

@ -29,16 +29,19 @@ fn elvish() {
}
static ELVISH: &str = r#"
use builtin;
use str;
edit:completion:arg-completer[my_app] = [@words]{
fn spaces [n]{
repeat $n ' ' | joins ''
builtin:repeat $n ' ' | str:join ''
}
fn cand [text desc]{
edit:complex-candidate $text &display-suffix=' '(spaces (- 14 (wcswidth $text)))$desc
}
command = 'my_app'
for word $words[1:-1] {
if (has-prefix $word '-') {
for word $words[1..-1] {
if (str:has-prefix $word '-') {
break
}
command = $command';'$word
@ -90,16 +93,19 @@ fn build_app_special_commands() -> App<'static> {
}
static ELVISH_SPECIAL_CMDS: &str = r#"
use builtin;
use str;
edit:completion:arg-completer[my_app] = [@words]{
fn spaces [n]{
repeat $n ' ' | joins ''
builtin:repeat $n ' ' | str:join ''
}
fn cand [text desc]{
edit:complex-candidate $text &display-suffix=' '(spaces (- 14 (wcswidth $text)))$desc
}
command = 'my_app'
for word $words[1:-1] {
if (has-prefix $word '-') {
for word $words[1..-1] {
if (str:has-prefix $word '-') {
break
}
command = $command';'$word
@ -176,16 +182,19 @@ fn build_app_with_aliases() -> App<'static> {
}
static ELVISH_ALIASES: &str = r#"
use builtin;
use str;
edit:completion:arg-completer[cmd] = [@words]{
fn spaces [n]{
repeat $n ' ' | joins ''
builtin:repeat $n ' ' | str:join ''
}
fn cand [text desc]{
edit:complex-candidate $text &display-suffix=' '(spaces (- 14 (wcswidth $text)))$desc
}
command = 'cmd'
for word $words[1:-1] {
if (has-prefix $word '-') {
for word $words[1..-1] {
if (str:has-prefix $word '-') {
break
}
command = $command';'$word