Prefix completion
Jeffrey Pfau jeffrey@endrift.com
Fri, 10 Oct 2014 03:27:10 -0700
1 files changed,
19 insertions(+),
2 deletions(-)
jump to
M
src/debugger/cli-debugger.c
→
src/debugger/cli-debugger.c
@@ -604,8 +604,25 @@ }
if (!name) { return CC_ERROR; } - if (_debuggerCommands[cmd + 1].name && strncasecmp(_debuggerCommands[cmd + 1].name, li->buffer, len - 1) == 0) { - return CC_ERROR; + if (_debuggerCommands[cmd + 1].name && name[len - 2] == _debuggerCommands[cmd + 1].name[len - 2]) { + --len; + const char* next = 0; + int i; + for (i = cmd + 1; _debuggerCommands[i].name; ++i) { + if (strncasecmp(name, _debuggerCommands[i].name, len)) { + break; + } + next = _debuggerCommands[i].name; + } + + for (; name[len]; ++len) { + if (name[len] != next[len]) { + break; + } + char out[2] = { name[len], '\0' }; + el_insertstr(elstate, out); + } + return CC_REDISPLAY; } name += len - 1; el_insertstr(elstate, name);