Use ints instead of unsigned for capture count
This commit is contained in:
parent
c24a636cb9
commit
7316afd17b
|
@ -759,8 +759,8 @@ void use_selection_as_search_pattern(Context& context, NormalParams params)
|
||||||
void select_regex(Context& context, NormalParams params)
|
void select_regex(Context& context, NormalParams params)
|
||||||
{
|
{
|
||||||
const char reg = to_lower(params.reg ? params.reg : '/');
|
const char reg = to_lower(params.reg ? params.reg : '/');
|
||||||
const unsigned capture = (unsigned)params.count;
|
const int capture = params.count;
|
||||||
auto prompt = capture ? format("select (capture {}):", (int)capture) : "select:"_str;
|
auto prompt = capture ? format("select (capture {}):", capture) : "select:"_str;
|
||||||
|
|
||||||
auto reg_content = RegisterManager::instance()[reg].values(context);
|
auto reg_content = RegisterManager::instance()[reg].values(context);
|
||||||
Vector<String> saved_reg{reg_content.begin(), reg_content.end()};
|
Vector<String> saved_reg{reg_content.begin(), reg_content.end()};
|
||||||
|
@ -786,7 +786,7 @@ void select_regex(Context& context, NormalParams params)
|
||||||
void split_regex(Context& context, NormalParams params)
|
void split_regex(Context& context, NormalParams params)
|
||||||
{
|
{
|
||||||
const char reg = to_lower(params.reg ? params.reg : '/');
|
const char reg = to_lower(params.reg ? params.reg : '/');
|
||||||
unsigned capture = (unsigned)params.count;
|
const int capture = params.count;
|
||||||
auto prompt = capture ? format("split (on capture {}):", (int)capture) : "split:"_str;
|
auto prompt = capture ? format("split (on capture {}):", (int)capture) : "split:"_str;
|
||||||
|
|
||||||
auto reg_content = RegisterManager::instance()[reg].values(context);
|
auto reg_content = RegisterManager::instance()[reg].values(context);
|
||||||
|
|
|
@ -841,10 +841,10 @@ template Selection find_next_match<Backward>(const Buffer&, const Selection&, co
|
||||||
|
|
||||||
using RegexIt = RegexIterator<BufferIterator>;
|
using RegexIt = RegexIterator<BufferIterator>;
|
||||||
|
|
||||||
void select_all_matches(SelectionList& selections, const Regex& regex, unsigned capture)
|
void select_all_matches(SelectionList& selections, const Regex& regex, int capture)
|
||||||
{
|
{
|
||||||
const unsigned mark_count = regex.mark_count();
|
const int mark_count = (int)regex.mark_count();
|
||||||
if (capture > mark_count)
|
if (capture < 0 or capture > mark_count)
|
||||||
throw runtime_error("invalid capture number");
|
throw runtime_error("invalid capture number");
|
||||||
|
|
||||||
Vector<Selection> result;
|
Vector<Selection> result;
|
||||||
|
@ -887,9 +887,9 @@ void select_all_matches(SelectionList& selections, const Regex& regex, unsigned
|
||||||
selections = SelectionList{buffer, std::move(result)};
|
selections = SelectionList{buffer, std::move(result)};
|
||||||
}
|
}
|
||||||
|
|
||||||
void split_selections(SelectionList& selections, const Regex& regex, unsigned capture)
|
void split_selections(SelectionList& selections, const Regex& regex, int capture)
|
||||||
{
|
{
|
||||||
if (capture > regex.mark_count())
|
if (capture < 0 or capture > (int)regex.mark_count())
|
||||||
throw runtime_error("invalid capture number");
|
throw runtime_error("invalid capture number");
|
||||||
|
|
||||||
Vector<Selection> result;
|
Vector<Selection> result;
|
||||||
|
|
|
@ -87,8 +87,8 @@ bool find_match_in_buffer(const Buffer& buffer, const BufferIterator pos,
|
||||||
template<Direction direction>
|
template<Direction direction>
|
||||||
Selection find_next_match(const Buffer& buffer, const Selection& sel, const Regex& regex, bool& wrapped);
|
Selection find_next_match(const Buffer& buffer, const Selection& sel, const Regex& regex, bool& wrapped);
|
||||||
|
|
||||||
void select_all_matches(SelectionList& selections, const Regex& regex, unsigned capture = 0);
|
void select_all_matches(SelectionList& selections, const Regex& regex, int capture = 0);
|
||||||
void split_selections(SelectionList& selections, const Regex& separator_regex, unsigned capture = 0);
|
void split_selections(SelectionList& selections, const Regex& separator_regex, int capture = 0);
|
||||||
|
|
||||||
Selection select_surrounding(const Buffer& buffer, const Selection& selection,
|
Selection select_surrounding(const Buffer& buffer, const Selection& selection,
|
||||||
StringView opening, StringView closing, int level,
|
StringView opening, StringView closing, int level,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user