summaryrefslogtreecommitdiff
path: root/src/click/types.py
diff options
context:
space:
mode:
authorFelix Nordén <felixnorden@gmail.com>2020-10-17 12:17:10 +0200
committerDavid Lord <davidism@gmail.com>2020-10-31 19:58:23 -0700
commitb964c1e2cba3915983a6e2f5fcb7f489acd9b33f (patch)
tree3146ab125b245935a14d68ed05568181c70b7e68 /src/click/types.py
parentacc91bc4f47e38f43277fcdfd8ca855734c4fbbc (diff)
downloadclick-b964c1e2cba3915983a6e2f5fcb7f489acd9b33f.tar.gz
handle case_sensitive=False when completing choices
Co-authored-by: David Lord <davidism@gmail.com>
Diffstat (limited to 'src/click/types.py')
-rw-r--r--src/click/types.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/click/types.py b/src/click/types.py
index 8c886d6..626287d 100644
--- a/src/click/types.py
+++ b/src/click/types.py
@@ -274,7 +274,14 @@ class Choice(ParamType):
from click.shell_completion import CompletionItem
str_choices = map(str, self.choices)
- return [CompletionItem(c) for c in str_choices if c.startswith(incomplete)]
+
+ if self.case_sensitive:
+ matched = (c for c in str_choices if c.startswith(incomplete))
+ else:
+ incomplete = incomplete.lower()
+ matched = (c for c in str_choices if c.lower().startswith(incomplete))
+
+ return [CompletionItem(c) for c in matched]
class DateTime(ParamType):