mirror of
https://github.com/bminor/binutils-gdb.git
synced 2025-12-26 01:07:52 +00:00
MI: extract command completion logic from complete_command()
Extract completion logic from CLI complete_command() into a new helper function complete(). gdb/Changelog: * completer.h (complete): New function. * completer.c (complete): Likewise. * cli/cli-cmds.c: (complete_command): Update to use new complete() function defined in completer.h.
This commit is contained in:
@@ -243,40 +243,13 @@ complete_command (const char *arg, int from_tty)
|
||||
if (arg == NULL)
|
||||
arg = "";
|
||||
|
||||
completion_tracker tracker_handle_brkchars;
|
||||
completion_tracker tracker_handle_completions;
|
||||
completion_tracker *tracker;
|
||||
|
||||
int quote_char = '\0';
|
||||
const char *word;
|
||||
|
||||
try
|
||||
{
|
||||
word = completion_find_completion_word (tracker_handle_brkchars,
|
||||
arg, "e_char);
|
||||
|
||||
/* Completers that provide a custom word point in the
|
||||
handle_brkchars phase also compute their completions then.
|
||||
Completers that leave the completion word handling to readline
|
||||
must be called twice. */
|
||||
if (tracker_handle_brkchars.use_custom_word_point ())
|
||||
tracker = &tracker_handle_brkchars;
|
||||
else
|
||||
{
|
||||
complete_line (tracker_handle_completions, word, arg, strlen (arg));
|
||||
tracker = &tracker_handle_completions;
|
||||
}
|
||||
}
|
||||
catch (const gdb_exception &ex)
|
||||
{
|
||||
return;
|
||||
}
|
||||
completion_result result = complete (arg, &word, "e_char);
|
||||
|
||||
std::string arg_prefix (arg, word - arg);
|
||||
|
||||
completion_result result
|
||||
= tracker->build_completion_result (word, word - arg, strlen (arg));
|
||||
|
||||
if (result.number_matches != 0)
|
||||
{
|
||||
if (result.number_matches == 1)
|
||||
|
||||
Reference in New Issue
Block a user