Skip to content

[Bug]: partial_match suffix check uses virtual_suggestion (prefix only) instead of full suggestion #62

Closed

Description

@github-actions
No description provided.

Activity

  1. PyDevC commented on May 24, 2026

    @PyDevC
    Owner

    /oc can you describe this issue?

  2. opencode-agent commented on May 24, 2026

    @opencode-agent

    Here's the bug analysis:

    The Bug

    In lua/model_cmp/utils.lua:82, the partial_match function checks if the suffix (text after cursor) exists in the suggestion, but it searches inside virtual_suggestion instead of the full suggestion.

    The problem

    virtual_suggestion is only the prefix portion of the suggestion (first #prefix characters), so when there's any text after the cursor, the suffix can never be found there, and the function always returns nil — rejecting even perfectly compatible suggestions.

    Example

    Buffer line: return 1;, cursor after return , model suggests return 1;:

    • prefix = "return ", suffix = "1;", suggestion = "return 1;"
    • virtual_suggestion = "return " (only first 7 chars)
    • string.find("return ", "1;") → nil → incorrectly rejected

    The fix on line 82 is to change virtual_suggestion → suggestion:

    - local s, _ = string.find(virtual_suggestion, suffix)
    + local s, _ = string.find(suggestion, suffix)

    Existing tests never hit this path because none of them have text after the cursor (curr == prefix in all cases, so suffix is always nil).

    New%20session%20-%202026-05-24T12%3A14%3A37.370Z
    opencode session  |  github run

  3. changed the title [-]bug: `partial_match` suffix check uses `virtual_suggestion` (prefix only) instead of full `suggestion`[/-] [+][Bug]: `partial_match` suffix check uses `virtual_suggestion` (prefix only) instead of full `suggestion`[/+] on May 26, 2026
  4. PyDevC commented on May 26, 2026

    @PyDevC
    Owner

    This doesn't seems right...

    The reason why I am doing virtual_suggestion instead of full suggestion is because I want it to just search for the prefix instead of full suggestions otherwise it will show suggestions even for words like is or and in between the sentences.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    AI genIssue was generated by AIbugSomething isn't workingmaintainer triagedmaintainer has triaged the issue

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions