Skip to content
Merged
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
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion mycli/main_modes/repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
20 changes: 17 additions & 3 deletions test/pytests/test_main_modes_repl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading