From 0c484fe725c8abb5fdf33be122240666462cbc9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nivaldo=20Bondan=C3=A7a?= Date: Fri, 22 Mar 2024 06:39:21 -0400 Subject: [PATCH 1/3] [completion] Fixed autocomplete issue when using aliases Right now if we try to use tab-complete with an alias, we get the following error (reproduced on a macOS and zsh): unrecognized modifier `i' Turns out the fix is quite simple, so here's the PR for it --- .../github/ajalt/clikt/completion/BashCompletionGenerator.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clikt/src/commonMain/kotlin/com/github/ajalt/clikt/completion/BashCompletionGenerator.kt b/clikt/src/commonMain/kotlin/com/github/ajalt/clikt/completion/BashCompletionGenerator.kt index a8fb7c4bf..cff272291 100644 --- a/clikt/src/commonMain/kotlin/com/github/ajalt/clikt/completion/BashCompletionGenerator.kt +++ b/clikt/src/commonMain/kotlin/com/github/ajalt/clikt/completion/BashCompletionGenerator.kt @@ -135,7 +135,7 @@ internal object BashCompletionGenerator { """ | $name) | (( i = i + 1 )) - | COMP_WORDS=( "${'$'}{COMP_WORDS[@]:0:i}" + | COMP_WORDS=( "${'$'}{COMP_WORDS[@]:0:${'$'}{i}}" """.trimMargin() ) toks.joinTo(this, " ", prefix = " ") { "'$it'" } From 41da8fa90afba508a5c49a5125564ff8eef8f04b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nivaldo=20Bondan=C3=A7a?= Date: Fri, 22 Mar 2024 06:45:17 -0400 Subject: [PATCH 2/3] Updated CHANGELOG --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6914d43f2..79db3d2b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,9 @@ - Added `limit` parameter to `option().counted()` to limit the number of times the option can be used. You can either clamp the value to the limit, or throw an error if the limit is exceeded. ([#483](https://github.com/ajalt/clikt/issues/483)) - Added `Context.registerClosable` and `Context.callOnClose` to allow you to register cleanup actions that will be called when the command exits. ([#395](https://github.com/ajalt/clikt/issues/395)) +### Fixed +- Fixed `unrecognized modifier 'i'` that happened on tab-completion when using sub command aliases + ## 4.2.2 ### Changed - Options and arguments can now reference option groups in their `defaultLazy` and other finalization blocks. They can also freely reference each other, including though chains of references. ([#473](https://github.com/ajalt/clikt/issues/473)) From 55d31ee4f82662bba4dfeab0296b18827e3e00b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nivaldo=20Bondan=C3=A7a?= Date: Fri, 22 Mar 2024 06:51:56 -0400 Subject: [PATCH 3/3] Linked PR in CHANGELOG --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 79db3d2b0..6680eaee3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ - Added `Context.registerClosable` and `Context.callOnClose` to allow you to register cleanup actions that will be called when the command exits. ([#395](https://github.com/ajalt/clikt/issues/395)) ### Fixed -- Fixed `unrecognized modifier 'i'` that happened on tab-completion when using sub command aliases +- Fixed `unrecognized modifier 'i'` that happened on tab-completion when using sub command aliases ([#500](https://github.com/ajalt/clikt/pull/500)) ## 4.2.2 ### Changed