[v3,16/19] Implement completion limiting for tui_reggroup_completer.
Commit Message
This is a new patch in the series.
--
This patch converts the (recently introduced) TUI register/group
completer, tui_reggroup_completer, to use add_completion.
gdb/ChangeLog
* tui/tui-regs.c (tui_reggroup_completer): Use add_completion
to add completions to the completion list.
gdb/testsuite/ChangeLog
* completion.exp: Add a completion-limit test for "tui reg".
---
gdb/testsuite/gdb.base/completion.exp | 5 +++++
gdb/tui/tui-regs.c | 6 +++++-
2 files changed, 10 insertions(+), 1 deletion(-)
Comments
Keith Seitz <keiths@redhat.com> writes:
> This is a new patch in the series.
>
> --
>
> This patch converts the (recently introduced) TUI register/group
> completer, tui_reggroup_completer, to use add_completion.
>
> gdb/ChangeLog
>
> * tui/tui-regs.c (tui_reggroup_completer): Use add_completion
> to add completions to the completion list.
>
> gdb/testsuite/ChangeLog
>
> * completion.exp: Add a completion-limit test for "tui reg".
LGTM
@@ -1058,6 +1058,11 @@ if {$signal_to_use != ""} {
test_completion_limit "print field_test_global.a" \
"print field_test_global\\\.a\[1-9\]_field" $max_completions
+# Test TUI's reg completer
+if {![skip_tui_tests]} {
+ test_completion_limit "tui reg " "tui reg \[a-z\]+" $max_completions
+}
+
#
# Test TUI completions
#
@@ -683,7 +683,11 @@ tui_reggroup_completer (struct completer_data *cdata,
for (tmp = extra; *tmp != NULL; ++tmp)
{
if (strncmp (word, *tmp, len) == 0)
- VEC_safe_push (char_ptr, result, xstrdup (*tmp));
+ {
+ if (add_completion (cdata, &result, *tmp, NULL, NULL)
+ == ADD_COMPLETION_MAX_REACHED)
+ break;
+ }
}
return result;