microsoft / microsoft/java-debug
CompletionItem of completions response always have `start = 0` and text prefix inclusion is mixed
还没有人认领这个 Issue。
- 主要语言
- Java
- 星标
- 409
- 派生
- 204
- 平均合并
- 1 天 13 小时
- 30 天内合并 PR
- 4
描述
I noticed recently that in nvim-dap, if you complete com. and select an entry you get com.com... inserted, so today I took a closer look and noticed that the responses from java-debug are somewhat odd - and I think incorrect.
With a client that specified columnsStartAt1 = true, and a completions payload like:
{
frameId = <frameId>,
text = "List.",
column = 6
}
The responses include:
}, {
label = "of(E e1, E e2, E e3, E e4) : List<E>",
number = 0,
sortText = "999999179",
start = 0,
text = "of()",
type = "function"
}, {
The specification says:
/**
- Start position (within the
textattribute of thecompletionsrequest)- where the completion text is added. The position is measured in UTF-16 code
- units and the client capability
columnsStartAt1determines whether it is- 0- or 1-based. If the start position is omitted the text is added at the
- location specified by the
columnattribute of thecompletionsrequest.
*/
start?: number;
The expected result for the user is to have List.of() if the completion candidate is selected. Now, start=0 is already odd given the columnsStartAt1, so a possible interpretation in the client is that it's absent, and that the client should just append .of()
This is kinda what I did in nvim-dap so far, and it works for the List.of case, and also for variables, but with a payload like:
{
column = 5,
frameId = <frameId>,
text = "com."
}
I get responses like:
}, {
label = "com.sun.tools.example",
number = 0,
sortText = "999999183",
start = 0,
text = "com.sun.tools.example",
type = "module"
}, {
Opposed to the List. result, here text includes the prefix com. and it's again start=0. This led to com.com.sun.tools.example
I suspect vscode does some kind of prefix matching on the client side again, so this isn't noticable there?
As far as I can tell, based on the specification the current behavior is wrong.
I used JDK 21 in my tests - in case it matters.
I can also provide some sample project if needed - but I tried to use examples that should behave similar with only the JDK as dependency
贡献指南
这个仓库没有索引到贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
首先使用报告中的 JDK 21 示例,跟踪 Java 调试服务器对 completions 请求和 CompletionItem 响应的 DAP 补全处理。使用 nvim-dap 等客户端重现 List. 和 com. 的情况,然后验证 start 和 text 遵循 DAP 规范,并且选择每个候选项都会插入预期的补全,而不会重复其前缀。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- java
- 领域
- devtools
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100