diff options
author | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2020-11-12 13:26:19 -0500 |
---|---|---|
committer | Kevin Van Brunt <kmvanbrunt@gmail.com> | 2020-11-12 13:26:19 -0500 |
commit | 59528a925300d67d05b5504441e0a4d7ea072acc (patch) | |
tree | 5dc896dd8b85b25545a77cd71f1d953fa967ed46 | |
parent | d4dc6b6a98fdb44b08701a3826ee88b6c22b72fd (diff) | |
download | cmd2-git-settable_hint.tar.gz |
Fixed bug where setting always_show_hint=True did not show a hint when completing Settablessettable_hint
-rw-r--r-- | CHANGELOG.md | 4 | ||||
-rw-r--r-- | cmd2/argparse_completer.py | 8 | ||||
-rwxr-xr-x | tests/test_completion.py | 1 |
3 files changed, 11 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index d20e678c..82b72ba4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.4.1 (TBD, 2020) +* Bug Fixes + * Fixed bug where setting `always_show_hint=True` did not show a hint when completing `Settables` + ## 1.4.0 (November 11, 2020) * Bug Fixes * Fixed tab completion crash on Windows diff --git a/cmd2/argparse_completer.py b/cmd2/argparse_completer.py index 7484358d..117bfd50 100644 --- a/cmd2/argparse_completer.py +++ b/cmd2/argparse_completer.py @@ -415,7 +415,9 @@ class ArgparseCompleter: # If we have results, then return them if completion_results: - self._cmd2_app.completion_hint = _build_hint(self._parser, flag_arg_state.action) + # Don't overwrite an existing hint + if not self._cmd2_app.completion_hint: + self._cmd2_app.completion_hint = _build_hint(self._parser, flag_arg_state.action) return completion_results # Otherwise, print a hint if the flag isn't finished or text isn't possibly the start of a flag @@ -437,7 +439,9 @@ class ArgparseCompleter: # If we have results, then return them if completion_results: - self._cmd2_app.completion_hint = _build_hint(self._parser, pos_arg_state.action) + # Don't overwrite an existing hint + if not self._cmd2_app.completion_hint: + self._cmd2_app.completion_hint = _build_hint(self._parser, pos_arg_state.action) return completion_results # Otherwise, print a hint if text isn't possibly the start of a flag diff --git a/tests/test_completion.py b/tests/test_completion.py index 48a055d0..db243f48 100755 --- a/tests/test_completion.py +++ b/tests/test_completion.py @@ -972,6 +972,7 @@ def test_complete_set_value(cmd2_app): first_match = complete_tester(text, line, begidx, endidx, cmd2_app) assert first_match == "SUCCESS " + assert cmd2_app.completion_hint == "Hint:\n value a settable param\n" def test_complete_set_value_invalid_settable(cmd2_app, capsys): text = '' |