Code cleanup in insert completer
This commit is contained in:
parent
246a32797a
commit
f6c67f7831
|
@ -261,10 +261,11 @@ InsertCompletion complete_option(const SelectionList& sels,
|
|||
auto& desc = opt.prefix;
|
||||
static const Regex re(R"((\d+)\.(\d+)(?:\+(\d+))?@(\d+))");
|
||||
MatchResults<String::const_iterator> match;
|
||||
if (regex_match(desc.begin(), desc.end(), match, re))
|
||||
{
|
||||
BufferCoord coord{ str_to_int({match[1].first, match[1].second}) - 1,
|
||||
str_to_int({match[2].first, match[2].second}) - 1 };
|
||||
if (not regex_match(desc.begin(), desc.end(), match, re))
|
||||
return {};
|
||||
|
||||
BufferCoord coord{str_to_int({match[1].first, match[1].second}) - 1,
|
||||
str_to_int({match[2].first, match[2].second}) - 1};
|
||||
if (not buffer.is_valid(coord))
|
||||
return {};
|
||||
size_t timestamp = (size_t)str_to_int({match[4].first, match[4].second});
|
||||
|
@ -272,9 +273,8 @@ InsertCompletion complete_option(const SelectionList& sels,
|
|||
if (any_of(changes, [&](auto&& change) { return change.begin < coord; }))
|
||||
return {};
|
||||
|
||||
if (cursor_pos.line == coord.line and cursor_pos.column >= coord.column)
|
||||
{
|
||||
StringView query = buffer.substr(coord, cursor_pos);
|
||||
if (cursor_pos.line != coord.line or cursor_pos.column < coord.column)
|
||||
return {};
|
||||
|
||||
const ColumnCount tabstop = options["tabstop"].get<int>();
|
||||
const ColumnCount column = get_column(buffer, tabstop, cursor_pos);
|
||||
|
@ -289,6 +289,7 @@ InsertCompletion complete_option(const SelectionList& sels,
|
|||
DisplayLine menu_entry;
|
||||
};
|
||||
|
||||
StringView query = buffer.substr(coord, cursor_pos);
|
||||
Vector<RankedMatchAndInfo> matches;
|
||||
|
||||
for (auto& candidate : opt.list)
|
||||
|
@ -299,7 +300,7 @@ InsertCompletion complete_option(const SelectionList& sels,
|
|||
auto& menu = std::get<2>(candidate);
|
||||
match.menu_entry = not menu.empty() ?
|
||||
parse_display_line(expand_tabs(menu, tabstop, column), faces)
|
||||
: DisplayLine{ expand_tabs(menu, tabstop, column), {} };
|
||||
: DisplayLine{String{}, {}};
|
||||
|
||||
matches.push_back(std::move(match));
|
||||
}
|
||||
|
@ -328,9 +329,6 @@ InsertCompletion complete_option(const SelectionList& sels,
|
|||
end = buffer.advance(coord, len);
|
||||
}
|
||||
return { std::move(candidates), coord, end, timestamp };
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
template<bool other_buffers>
|
||||
|
|
Loading…
Reference in New Issue
Block a user