Skip to content

Add 2 index parameters to custom shell completion function calls #757

Closed
@rgoldberg

Description

@rgoldberg

Replace this paragraph with a short description of the incorrect incorrect behavior. If this is a regression, please note the last version that the behavior was correct in addition to your current version.

ArgumentParser version: All versions
Swift version: n/a

Checklist

  • If possible, I've reproduced the issue using the main branch of this package
  • I've searched for existing GitHub issues

Steps to Reproduce

To resolve this, 2 extra arguments should be passed to Swift custom completion functions (I will leave the existing single-argument function as is but deprecate it, and add & recommend the new overload).

New arguments:

  1. 0-based index of the word for which completion candidates are being requested. This is necessary because bash & zsh include all command-line words that are after the word for which completions are being requested (after Improve fish completion script generation #738 has been merged, fish 4+ will also include such words). Without this new index, there's no way of knowing the word for which completions are being requested.

  2. 0-based index of the location of the cursor within the word for which completion candidates are being requested. This is useful because a user could request completions from just before any character in the word, or at the end of the word. A custom Swift completion function might like to know the exact cursor location.

Expected behavior

Being able to determine exactly for which word completions are being requested, and where in that word the cursor is located.

Actual behavior

Cannot do so.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions