Fix tab completion
FossilOrigin-Name: 2200947ce957ddb35e68f3d631cc4b7171394ea06302fdb9ce624f1aebf8584c
This commit is contained in:
parent
8f9f02c270
commit
d4b7da3740
2 changed files with 12 additions and 19 deletions
|
@ -298,36 +298,29 @@ resetcomplete()
|
|||
}
|
||||
|
||||
void
|
||||
complete(OFString *s_)
|
||||
complete(OFMutableString *s)
|
||||
{
|
||||
@autoreleasepool {
|
||||
std::unique_ptr<char> copy(strdup(s_.UTF8String));
|
||||
char *s = copy.get();
|
||||
if (![s hasPrefix:@"/"])
|
||||
[s insertString:@"/" atIndex:0];
|
||||
|
||||
if (*s != '/') {
|
||||
string t;
|
||||
strcpy_s(t, s);
|
||||
strcpy_s(s, "/");
|
||||
strcat_s(s, t);
|
||||
}
|
||||
|
||||
if (!s[1])
|
||||
if (s.length == 1)
|
||||
return;
|
||||
|
||||
if (!completesize) {
|
||||
completesize = strlen(s) - 1;
|
||||
completesize = s.length - 1;
|
||||
completeidx = 0;
|
||||
}
|
||||
|
||||
__block int idx = 0;
|
||||
[identifiers enumerateKeysAndObjectsUsingBlock:^(
|
||||
OFString *name, Identifier *identifier, bool *stop) {
|
||||
if (strncmp(identifier.name.UTF8String, s + 1,
|
||||
completesize) == 0 &&
|
||||
idx++ == completeidx) {
|
||||
strcpy_s(s, "/");
|
||||
strcat_s(s, identifier.name.UTF8String);
|
||||
}
|
||||
if (strncmp(identifier.name.UTF8String,
|
||||
s.UTF8String + 1, completesize) == 0 &&
|
||||
idx++ == completeidx)
|
||||
[s replaceCharactersInRange:OFMakeRange(
|
||||
1, s.length - 1)
|
||||
withString:identifier.name];
|
||||
}];
|
||||
|
||||
completeidx++;
|
||||
|
|
|
@ -11,7 +11,7 @@ extern int execute(OFString *p, bool down = true);
|
|||
extern void exec(OFString *cfgfile);
|
||||
extern bool execfile(OFIRI *cfgfile);
|
||||
extern void resetcomplete();
|
||||
extern void complete(OFString *s);
|
||||
extern void complete(OFMutableString *s);
|
||||
extern void alias(OFString *name, OFString *action);
|
||||
extern OFString *getalias(OFString *name);
|
||||
extern void writecfg();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue