Skip to content

Shell completions should ignore parentheses inside strings and regex literals #710

@hanhan761

Description

@hanhan761

Problem

ShellCompletionProvider.detectMethodArgContext() determines whether the cursor is inside a collection method call by scanning backward and counting raw ( / ) characters. The scanner does not ignore parentheses that appear inside quoted strings or regex literals.

That can make the provider miss the real method-call boundary and suppress completions while the user is still editing a valid query object.

Repro examples

db.users.find({ note: ")", na| })
db.users.find({ name: /foo(bar)/, ag| })

At the cursor, field-name completions should still be available for the find() filter object.

Expected behavior

Parentheses inside string literals, regex literals, and comments should not affect method-argument context detection.

Current behavior

A literal ) inside input such as ")" or /foo(bar)/ can change the depth calculation and cause completions to disappear.

Notes

This is called out in docs/ai-and-plans/shell-autocompletion/9-shell-autocompletion-review.md under review item #21.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions