Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Can you replace user's input when using CompletionProposal?

未关闭
#1,097 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
5/5
预计耗时
一周以上
新手友好度
35/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
停滞
技术栈
java
领域
cli

调研方向

Start by inspecting CompletionProposal and its displayText, category, and description methods. Determine how completion matching and replacement currently use the proposal text. Done means search terms such as enum properties or descriptive names can select a proposal while replacing the input with its final value and showing a clear label to the user.

由索引模型根据 Issue 内容生成。

描述

status/need-triage

Let's say the options are an enum of DayOfWeek; and each day has an associated number and color (just for the sake of an example).

public enum DayOfWeek {
    MONDAY(0, "yellow"),
    TUESDAY(1, "blue"),
    WEDNESDAY(2, "pink"),
    THURSDAY(3, "purple"),
    FRIDAY(4, "orange"),
    SATURDAY(5, "green"),
    SUNDAY(6, "red");

    public int num;
    public String color;

    public DayOfWeek(int num, String color) {
        this.num = num;
        this.color = color;
    }

    public static List<CompletionProposal> completion() {
        return Arrays.stream(values()).map(Enum::name).map(CompletionProposal::new).toList();
    }
}

I want the user to get autocomplete with all the properties, in addition to the enum name.

If I give the List<CompletionProposal> of the names of the enum constants, this will work:
MON -> MONDAY

What if I want the user to type gre or green and then have it change to SATURDAY?

Even if that is not possible, what if I type satur? It won't autocomplete to SATURDAY or saturday, unless I include the day twice as upper and lower cases, which is confusing to the user.

The only way I can think of showing it to the user is to use the displayText, category, or description method to the user, but it's still a chore to type exactly the words.

In my case I have IDs of a huge list, and the user won't remember the entire IDs of the list, so I would like them to autocomplete with a sort of a "search" feature. Let's say I type "Mark Twain" or "Tom Sawyer", I want to get "94782293" to replace the words I typed, since the final value will be an ID, but the other words help search. So far I'm using displayText as Tom Sawyer by Mark Twain: 94782293, but the value is 94782293, which is obscuring what's happening to the user.

主要语言
Java
星标
826
派生
404
平均合并
6 天 9 小时
30 天内合并 PR
1

环境准备

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

spring-projects/spring-shell 的其他 Issue

查看 spring-projects/spring-shell 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。