Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Breaking Changes
Features
---------
* Add `--warn-batch` flag, which is off by default.
* Override `min_completion_trigger` for the `/command` form.


Bug Fixes
Expand Down
2 changes: 2 additions & 0 deletions mycli/main_modes/repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ def complete_while_typing_filter() -> bool:
return True
app = get_app()
text = app.current_buffer.text.lstrip()
if text.startswith('/') and not text.startswith('/*'):
return True
text_len = len(text)
if text_len < MIN_COMPLETION_TRIGGER:
return False
Expand Down
3 changes: 2 additions & 1 deletion mycli/myclirc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ show_warnings = False
# possible completions will be listed.
smart_completion = True

# Minimum characters typed before offering completion suggestions.
# Minimum characters typed before offering completion suggestions. Forward
# slash for a command is an exception which always offers completions.
# Suggestion: 3.
min_completion_trigger = 1

Expand Down
3 changes: 2 additions & 1 deletion test/myclirc
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ show_warnings = False
# possible completions will be listed.
smart_completion = True

# Minimum characters typed before offering completion suggestions.
# Minimum characters typed before offering completion suggestions. Forward
# slash for a command is an exception which always offers completions.
# Suggestion: 3.
min_completion_trigger = 1

Expand Down
18 changes: 18 additions & 0 deletions test/pytests/test_main_modes_repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,24 @@ 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(
monkeypatch: pytest.MonkeyPatch,
) -> None:
monkeypatch.setattr(repl_mode, 'MIN_COMPLETION_TRIGGER', 3)
monkeypatch.setattr(repl_mode, 'get_app', lambda: SimpleNamespace(current_buffer=SimpleNamespace(text='/')))

assert repl_mode.complete_while_typing_filter() is True


def test_complete_while_typing_filter_does_not_treat_block_comments_as_slash_commands(
monkeypatch: pytest.MonkeyPatch,
) -> None:
monkeypatch.setattr(repl_mode, 'MIN_COMPLETION_TRIGGER', 3)
monkeypatch.setattr(repl_mode, 'get_app', lambda: SimpleNamespace(current_buffer=SimpleNamespace(text='/*')))

assert repl_mode.complete_while_typing_filter() is False


def test_repl_create_history(monkeypatch: pytest.MonkeyPatch) -> None:
cli = make_repl_cli()
monkeypatch.setenv('MYCLI_HISTFILE', '~/override-history')
Expand Down
Loading