summaryrefslogtreecommitdiff
path: root/src/normal.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2016-02-28 18:30:35 +0000
committerMaxime Coste <frrrwww@gmail.com>2016-02-28 18:30:35 +0000
commit548e10597c7145babb7b68cf3bf42a4c6ed81ec9 (patch)
tree6be96c28de426fb78f0240e3caac608a3e1ac024 /src/normal.cc
parentaa39380f4b627563a3b3c3e4940f775b86272a7c (diff)
Code cleanup
Diffstat (limited to 'src/normal.cc')
-rw-r--r--src/normal.cc15
1 files changed, 6 insertions, 9 deletions
diff --git a/src/normal.cc b/src/normal.cc
index eaa33159..81a337dd 100644
--- a/src/normal.cc
+++ b/src/normal.cc
@@ -172,18 +172,15 @@ void goto_commands(Context& context, NormalParams params)
}
case 'f':
{
- const Selection& sel = context.selections().main();
- String filename = content(buffer, sel);
+ auto filename = content(buffer, context.selections().main());
static constexpr char forbidden[] = { '\'', '\\', '\0' };
- for (auto c : filename)
- if (contains(forbidden, c))
- return;
+ if (contains_that(filename, [](char c){ return contains(forbidden, c); }))
+ return;
auto paths = context.options()["path"].get<Vector<String, MemoryDomain::Options>>();
- const String& buffer_name = buffer.name();
- auto it = find(reversed(buffer_name), '/');
- if (it != buffer_name.rend())
- paths.insert(paths.begin(), String{buffer_name.begin(), it.base()});
+ StringView buffer_dir = split_path(buffer.name()).first;
+ if (not buffer_dir.empty())
+ paths.insert(paths.begin(), buffer_dir.str());
String path = find_file(filename, paths);
if (path.empty())