Make ArrayView::subrange size arguement optional
This commit is contained in:
parent
f7ab017b6a
commit
47a82b9855
|
@ -60,9 +60,10 @@ public:
|
|||
|
||||
constexpr bool empty() const { return m_size == 0; }
|
||||
|
||||
constexpr ArrayView subrange(size_t first, size_t count) const
|
||||
constexpr ArrayView subrange(size_t first, size_t count = -1) const
|
||||
{
|
||||
return ArrayView(m_pointer + first, count);
|
||||
return ArrayView(m_pointer + std::min(first, m_size),
|
||||
std::min(count, m_size - std::min(first, m_size)));
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -662,7 +662,7 @@ Completions CommandManager::complete(const Context& context,
|
|||
auto command_it = find_command(context, command_name);
|
||||
if (command_it != m_commands.end() and command_it->second.completer)
|
||||
return command_it->second.completer(
|
||||
context, flags, params.subrange(1, params.size()-1),
|
||||
context, flags, params.subrange(1),
|
||||
token_to_complete-1, pos_in_token);
|
||||
}
|
||||
return Completions{};
|
||||
|
|
|
@ -250,7 +250,7 @@ public:
|
|||
throw runtime_error("wrong parameter count");
|
||||
|
||||
FacesSpec faces;
|
||||
for (auto& spec : params.subrange(1, params.size()-1))
|
||||
for (auto& spec : params.subrange(1))
|
||||
{
|
||||
auto colon = find(spec, ':');
|
||||
if (colon == spec.end())
|
||||
|
@ -440,7 +440,7 @@ HighlighterAndId create_dynamic_regex_highlighter(HighlighterParameters params)
|
|||
throw runtime_error("Wrong parameter count");
|
||||
|
||||
FacesSpec faces;
|
||||
for (auto& spec : params.subrange(1, params.size()-1))
|
||||
for (auto& spec : params.subrange(1))
|
||||
{
|
||||
auto colon = find(spec, ':');
|
||||
if (colon == spec.end())
|
||||
|
|
Loading…
Reference in New Issue
Block a user