fish-shell/src/operation_context.cpp
ridiculousfish a8080e8e6f 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.
2020-12-22 12:38:51 -08:00

27 lines
855 B
C++

// Utilities for io redirection.
#include "config.h" // IWYU pragma: keep
#include "operation_context.h"
#include "env.h"
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,
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{};
return operation_context_t{nullenv};
}
operation_context_t operation_context_t::globals() {
return operation_context_t{env_stack_t::globals()};
}
operation_context_t::~operation_context_t() = default;