@@ -448,17 +448,16 @@ def _is_incomplete_argument(ctx: Context, param: Parameter) -> bool:
448448 )
449449
450450
451- def _start_of_option (value : str ) -> bool :
451+ def _start_of_option (ctx : Context , value : str ) -> bool :
452452 """Check if the value looks like the start of an option."""
453453 if not value :
454454 return False
455455
456456 c = value [0 ]
457- # Allow "/" since that starts a path.
458- return not c .isalnum () and c != "/"
457+ return c in ctx ._opt_prefixes
459458
460459
461- def _is_incomplete_option (args : t .List [str ], param : Parameter ) -> bool :
460+ def _is_incomplete_option (ctx : Context , args : t .List [str ], param : Parameter ) -> bool :
462461 """Determine if the given parameter is an option that needs a value.
463462
464463 :param args: List of complete args before the incomplete value.
@@ -467,7 +466,7 @@ def _is_incomplete_option(args: t.List[str], param: Parameter) -> bool:
467466 if not isinstance (param , Option ):
468467 return False
469468
470- if param .is_flag :
469+ if param .is_flag or param . count :
471470 return False
472471
473472 last_option = None
@@ -476,7 +475,7 @@ def _is_incomplete_option(args: t.List[str], param: Parameter) -> bool:
476475 if index + 1 > param .nargs :
477476 break
478477
479- if _start_of_option (arg ):
478+ if _start_of_option (ctx , arg ):
480479 last_option = arg
481480
482481 return last_option is not None and last_option in param .opts
@@ -551,23 +550,23 @@ def _resolve_incomplete(
551550 # split and discard the "=" to make completion easier.
552551 if incomplete == "=" :
553552 incomplete = ""
554- elif "=" in incomplete and _start_of_option (incomplete ):
553+ elif "=" in incomplete and _start_of_option (ctx , incomplete ):
555554 name , _ , incomplete = incomplete .partition ("=" )
556555 args .append (name )
557556
558557 # The "--" marker tells Click to stop treating values as options
559558 # even if they start with the option character. If it hasn't been
560559 # given and the incomplete arg looks like an option, the current
561560 # command will provide option name completions.
562- if "--" not in args and _start_of_option (incomplete ):
561+ if "--" not in args and _start_of_option (ctx , incomplete ):
563562 return ctx .command , incomplete
564563
565564 params = ctx .command .get_params (ctx )
566565
567566 # If the last complete arg is an option name with an incomplete
568567 # value, the option will provide value completions.
569568 for param in params :
570- if _is_incomplete_option (args , param ):
569+ if _is_incomplete_option (ctx , args , param ):
571570 return param , incomplete
572571
573572 # It's not an option name or value. The first argument without a
0 commit comments