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
|
void
|
||||||
complete(OFString *s_)
|
complete(OFMutableString *s)
|
||||||
{
|
{
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
std::unique_ptr<char> copy(strdup(s_.UTF8String));
|
if (![s hasPrefix:@"/"])
|
||||||
char *s = copy.get();
|
[s insertString:@"/" atIndex:0];
|
||||||
|
|
||||||
if (*s != '/') {
|
if (s.length == 1)
|
||||||
string t;
|
|
||||||
strcpy_s(t, s);
|
|
||||||
strcpy_s(s, "/");
|
|
||||||
strcat_s(s, t);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!s[1])
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!completesize) {
|
if (!completesize) {
|
||||||
completesize = strlen(s) - 1;
|
completesize = s.length - 1;
|
||||||
completeidx = 0;
|
completeidx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
__block int idx = 0;
|
__block int idx = 0;
|
||||||
[identifiers enumerateKeysAndObjectsUsingBlock:^(
|
[identifiers enumerateKeysAndObjectsUsingBlock:^(
|
||||||
OFString *name, Identifier *identifier, bool *stop) {
|
OFString *name, Identifier *identifier, bool *stop) {
|
||||||
if (strncmp(identifier.name.UTF8String, s + 1,
|
if (strncmp(identifier.name.UTF8String,
|
||||||
completesize) == 0 &&
|
s.UTF8String + 1, completesize) == 0 &&
|
||||||
idx++ == completeidx) {
|
idx++ == completeidx)
|
||||||
strcpy_s(s, "/");
|
[s replaceCharactersInRange:OFMakeRange(
|
||||||
strcat_s(s, identifier.name.UTF8String);
|
1, s.length - 1)
|
||||||
}
|
withString:identifier.name];
|
||||||
}];
|
}];
|
||||||
|
|
||||||
completeidx++;
|
completeidx++;
|
||||||
|
|
|
@ -11,7 +11,7 @@ extern int execute(OFString *p, bool down = true);
|
||||||
extern void exec(OFString *cfgfile);
|
extern void exec(OFString *cfgfile);
|
||||||
extern bool execfile(OFIRI *cfgfile);
|
extern bool execfile(OFIRI *cfgfile);
|
||||||
extern void resetcomplete();
|
extern void resetcomplete();
|
||||||
extern void complete(OFString *s);
|
extern void complete(OFMutableString *s);
|
||||||
extern void alias(OFString *name, OFString *action);
|
extern void alias(OFString *name, OFString *action);
|
||||||
extern OFString *getalias(OFString *name);
|
extern OFString *getalias(OFString *name);
|
||||||
extern void writecfg();
|
extern void writecfg();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue