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

@@ -138,7 +138,7 @@ static operation_context_t get_bg_context(const std::shared_ptr<environment_t> &
// Cancel if the generation count changed.
return generation_count != read_generation_count();
};
return operation_context_t{nullptr, *env, std::move(cancel_checker)};
return operation_context_t{nullptr, *env, std::move(cancel_checker), kExpansionLimitBackground};
}
/// We try to ensure that syntax highlighting completes appropriately before executing what the user