* [PATCH] gdb/dap: stop setting CompletionItem.length
@ 2026-08-01 16:02 Oleg Tolmatcev
2026-08-21 15:49 ` Tom Tromey
0 siblings, 1 reply; 2+ messages in thread
From: Oleg Tolmatcev @ 2026-08-01 16:02 UTC (permalink / raw)
To: gdb-patches; +Cc: Oleg Tolmatcev
Do not set the CompletionItem.length field in completions responses.
According to the DAP spec, length says how many characters the
completion text should overwrite. It is not the length of the
completion label, so using the label length here is wrong.
---
gdb/python/lib/gdb/dap/completions.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gdb/python/lib/gdb/dap/completions.py b/gdb/python/lib/gdb/dap/completions.py
index 5cc6e025ee5..fb8f078d046 100644
--- a/gdb/python/lib/gdb/dap/completions.py
+++ b/gdb/python/lib/gdb/dap/completions.py
@@ -49,7 +49,7 @@ def completions(
completion = None
if "completion" in mi_result:
completion = mi_result["completion"]
- result.append({"label": completion, "length": len(completion)})
+ result.append({"label": completion})
# If `-complete' finds one match then `completion' and `matches'
# will contain the same one match.
if (
@@ -59,5 +59,5 @@ def completions(
):
return {"targets": result}
for match in mi_result["matches"]:
- result.append({"label": match, "length": len(match)})
+ result.append({"label": match})
return {"targets": result}
--
2.55.0.windows.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] gdb/dap: stop setting CompletionItem.length
2026-08-01 16:02 [PATCH] gdb/dap: stop setting CompletionItem.length Oleg Tolmatcev
@ 2026-08-21 15:49 ` Tom Tromey
0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2026-08-21 15:49 UTC (permalink / raw)
To: Oleg Tolmatcev; +Cc: gdb-patches
>>>>> "Oleg" == Oleg Tolmatcev <oleg.tolmatcev@gmail.com> writes:
Oleg> Do not set the CompletionItem.length field in completions responses.
Oleg> According to the DAP spec, length says how many characters the
Oleg> completion text should overwrite. It is not the length of the
Oleg> completion label, so using the label length here is wrong.
I am not so sure about this.
The spec says:
/**
* Length determines how many characters are overwritten by the completion
* text and it is measured in UTF-16 code units. If missing the value 0 is
* assumed which results in the completion text being inserted.
*/
length?: number;
But IIUC the gdb 'completions' result will also include whatever prefix
was supplied.
So for instance I think if we try to complete "print" we might get
results like "print_this" and "print_that". But here we wouldn't want
to report length=0, because wouldn't that mean "the completion text
being inserted" would result in "printprint_this" and "printprint_that"?
Tom
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-21 15:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-01 16:02 [PATCH] gdb/dap: stop setting CompletionItem.length Oleg Tolmatcev
2026-08-21 15:49 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox