X-Git-Url: http://g0dil.de/git?a=blobdiff_plain;f=Utils%2FConsole%2FLineEditor.cc;h=bf4d86936ca0d940b7a8c10c6db6d2dd2e027b29;hb=a726ae0cb14d0ce37e5aab3c4e07121bbbd3b31c;hp=95f1153b706f5fea45e4fe347b9929bfe77e153f;hpb=0461eef93912cb9d454d726b4a7b4ccf50ed31bd;p=senf.git diff --git a/Utils/Console/LineEditor.cc b/Utils/Console/LineEditor.cc index 95f1153..bf4d869 100644 --- a/Utils/Console/LineEditor.cc +++ b/Utils/Console/LineEditor.cc @@ -144,11 +144,8 @@ completePath(term::LineEditor & editor, unsigned b, unsigned e, ParseCommandInfo::TokensRange path (cmd.commandPath()); if (path.empty()) { DirectoryNode::ChildrenRange cs (client().cwd().children()); - for (DirectoryNode::ChildrenRange::iterator i (cs.begin()); i != cs.end(); ++i) { - completions.push_back(i->first); - if (i->second->isDirectory()) - completions.push_back(i->first + "/"); - } + for (DirectoryNode::ChildrenRange::iterator i (cs.begin()); i != cs.end(); ++i) + completions.push_back(i->first + (i->second->isDirectory() ? "/" : "")); return; } @@ -169,17 +166,21 @@ completePath(term::LineEditor & editor, unsigned b, unsigned e, basePath += "../"; } else if (*i == WordToken(".")) - ; + basePath += "./"; else { if (dir->hasChild(i->value())) { - dir = & dir->getDirectory(i->value()); + try { + dir = & dir->getDirectory(i->value()); + } + catch (std::bad_cast &) { + return; + } basePath += i->value() + "/"; - } else { + } + else { DirectoryNode::ChildrenRange cs (dir->completions(i->value())); if (has_one_elt(cs)) { GenericNode * node (cs.begin()->second.get()); - if (node->isLink()) - node = & static_cast(node)->follow(); if (!node->isDirectory()) return; dir = static_cast(node); @@ -191,11 +192,8 @@ completePath(term::LineEditor & editor, unsigned b, unsigned e, } DirectoryNode::ChildrenRange cs (dir->completions(i->value())); - for (DirectoryNode::ChildrenRange::iterator j (cs.begin()); j != cs.end(); ++j) { - completions.push_back(basePath + j->first); - if (j->second->isDirectory()) - completions.push_back(basePath + j->first + "/"); - } + for (DirectoryNode::ChildrenRange::iterator j (cs.begin()); j != cs.end(); ++j) + completions.push_back(basePath + j->first + (j->second->isDirectory() ? "/" : "")); } ///////////////////////////////cc.e////////////////////////////////////////