Allow specifying a limit on number of expansion in operation_context

If the user types something like `/**`, prior to this change we would
attempt to expand it in the background for both highlighting and
autosuggestions. This could thrash your disk and also consume a lot of
memory.

Add a a field to operation_context_t to allow specifying a limit, and add
a "default background" limit of 512 items.
This commit is contained in:
ridiculousfish
2020-12-20 11:58:26 -08:00
parent 0f2d73e4a3
commit a8080e8e6f
6 changed files with 26 additions and 18 deletions

View File

@@ -8,8 +8,12 @@
bool no_cancel() { return false; }
operation_context_t::operation_context_t(std::shared_ptr<parser_t> parser,
const environment_t &vars, cancel_checker_t cancel_checker)
: parser(std::move(parser)), vars(vars), cancel_checker(std::move(cancel_checker)) {}
const environment_t &vars, cancel_checker_t cancel_checker,
size_t expansion_limit)
: parser(std::move(parser)),
vars(vars),
expansion_limit(expansion_limit),
cancel_checker(std::move(cancel_checker)) {}
operation_context_t operation_context_t::empty() {
static const null_environment_t nullenv{};