Skip to content

Commit aed5eee

Browse files
Jorenartromey
authored andcommitted
gdb/dap: fix completion request for empty strings
When DAP completion requests receives empty string to complete, the script crashes due trying to access element -1 from list being a result of `text.splitlines()` (which for `text == ""` evaluates into empty list). This patch adds simple check if `text` is populated, and when it is not, skips transformations and assigns correct result directly. Approved-By: Tom Tromey <[email protected]>
1 parent bc5237a commit aed5eee

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

gdb/python/lib/gdb/dap/completions.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,11 @@ def completions(
3939
line = 1
4040
else:
4141
line = import_line(line)
42-
text = text.splitlines()[line - 1]
43-
text = text[: column - 1]
42+
if text:
43+
text = text.splitlines()[line - 1]
44+
text = text[: column - 1]
45+
else:
46+
text = ""
4447
mi_result = exec_mi_and_log("-complete", text)
4548
result = []
4649
completion = None

0 commit comments

Comments
 (0)