From cd1298c5a8eff9f944270b988685b69697282469 Mon Sep 17 00:00:00 2001 From: Roland Walker Date: Sat, 25 Jul 2026 14:42:30 -0400 Subject: [PATCH] only ignore completion trigger for /command term Ignoring min_completion_trigger when the line starts with forward slash helps prompt for possible commands, but the previous implementation suppressed the setting throughout the entire line, applying also to the subcommands and further arguments of /command. Instead, the user's setting should be generally respected, and ignored _only_ for the first term, when /command is typed. --- changelog.md | 5 +++++ mycli/main_modes/repl.py | 2 +- test/pytests/test_main_modes_repl.py | 20 +++++++++++++++++--- 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/changelog.md b/changelog.md index 58a59c7d..e72c0cc9 100644 --- a/changelog.md +++ b/changelog.md @@ -9,6 +9,11 @@ Features * Highlight indexed columns in completions with a suffix and/or a text style. +Bugfixes +--------- +* Ignoring `min_completion_trigger` only applies to first token after `/`. + + Documentation --------- * Add `.|` and `.>` to TIPS. diff --git a/mycli/main_modes/repl.py b/mycli/main_modes/repl.py index e09cd690..3f7b5581 100644 --- a/mycli/main_modes/repl.py +++ b/mycli/main_modes/repl.py @@ -112,7 +112,7 @@ def complete_while_typing_filter() -> bool: return True app = get_app() text = app.current_buffer.text.lstrip() - if text.startswith('/') and not text.startswith('/*'): + if text.startswith('/') and not text.startswith('/*') and ' ' not in text: return True text_len = len(text) if text_len < MIN_COMPLETION_TRIGGER: diff --git a/test/pytests/test_main_modes_repl.py b/test/pytests/test_main_modes_repl.py index 78b728fc..6c451ecc 100644 --- a/test/pytests/test_main_modes_repl.py +++ b/test/pytests/test_main_modes_repl.py @@ -288,13 +288,27 @@ def test_complete_while_typing_filter_covers_threshold_and_word_rules(monkeypatc assert repl_mode.complete_while_typing_filter() is True -def test_complete_while_typing_filter_always_completes_slash_commands( +@pytest.mark.parametrize( + ('text', 'expected'), + [ + ('/', True), + ('/d', True), + ('/dsn', True), + (' /d', True), + ('/dsn ', False), + ('/dsn d', False), + ('/dsn del', True), + ], +) +def test_complete_while_typing_filter_bypasses_threshold_for_initial_slash_command_only( monkeypatch: pytest.MonkeyPatch, + text: str, + expected: bool, ) -> None: monkeypatch.setattr(repl_mode, 'MIN_COMPLETION_TRIGGER', 3) - monkeypatch.setattr(repl_mode, 'get_app', lambda: SimpleNamespace(current_buffer=SimpleNamespace(text='/'))) + monkeypatch.setattr(repl_mode, 'get_app', lambda: SimpleNamespace(current_buffer=SimpleNamespace(text=text))) - assert repl_mode.complete_while_typing_filter() is True + assert repl_mode.complete_while_typing_filter() is expected def test_complete_while_typing_filter_does_not_treat_block_comments_as_slash_commands(