Code cleanup
This commit is contained in:
parent
aa39380f4b
commit
548e10597c
|
@ -162,6 +162,12 @@ bool contains(Container&& container, const T& value)
|
|||
return find(container, value) != end(container);
|
||||
}
|
||||
|
||||
template<typename Container, typename T>
|
||||
bool contains_that(Container&& container, T op)
|
||||
{
|
||||
return find_if(container, op) != end(container);
|
||||
}
|
||||
|
||||
template<typename Container, typename U>
|
||||
void unordered_erase(Container&& vec, U&& value)
|
||||
{
|
||||
|
|
|
@ -241,9 +241,8 @@ InsertCompletion complete_option(const Buffer& buffer, ByteCoord cursor_pos,
|
|||
}
|
||||
size_t timestamp = (size_t)str_to_int({match[4].first, match[4].second});
|
||||
auto changes = buffer.changes_since(timestamp);
|
||||
if (find_if(changes, [&](const Buffer::Change& change){
|
||||
return change.begin < coord;
|
||||
}) != changes.end())
|
||||
if (contains_that(changes, [&](const Buffer::Change& change)
|
||||
{ return change.begin < coord; }))
|
||||
return {};
|
||||
|
||||
if (cursor_pos.line == coord.line and cursor_pos.column >= coord.column)
|
||||
|
|
|
@ -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))
|
||||
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())
|
||||
|
|
|
@ -90,7 +90,7 @@ Vector<String> generate_env(StringView cmdline, const Context& context, const Sh
|
|||
return s.length() > name.length() and
|
||||
prefix_match(s, name) and s[name.length()] == '=';
|
||||
};
|
||||
if (find_if(kak_env, match_name) != kak_env.end())
|
||||
if (contains_that(kak_env, match_name))
|
||||
continue;
|
||||
|
||||
auto var_it = shell_context.env_vars.find(name);
|
||||
|
|
Loading…
Reference in New Issue
Block a user