click-contrib / click-repl

Subcommand REPL for click apps
MIT License
215 stars 41 forks source link

Entering ". ", "/ ", etc.. shows usage #113

Open thomask77 opened 5 months ago

thomask77 commented 5 months ago

If you enter ". ", "/ " or similar, as soon as you hit space, the usage is displayed.

As a workaround, I added the following code in _completer.py:

diff --git a/Tests/click/third_party/click_repl/_completer.py b/Tests/click/third_party/click_repl/_completer.py
index 67b8bda..6f531db 100644
--- a/Tests/click/third_party/click_repl/_completer.py
+++ b/Tests/click/third_party/click_repl/_completer.py
@@ -275,6 +275,17 @@ class ClickCompleter(Completer):
         if self.parsed_args != args:
             self.parsed_args = args
             try:
+                # 2024-01-24, tk:
+                #
+                # Without resilient_parsing, entering ". ", "^ ", etc..
+                # prints the usage. (But not "x " - strange!)
+                #
+                # I'm not sure, if this is the correct place to fix it.
+                #
+                # See https://github.com/click-contrib/click-repl/issues/113
+                #
+                self.ctx.resilient_parsing = True
+