Allow turning off autosuggestions

This adds a variable, $fish_autosuggestion_enabled.

When set to 0, it will turn off autosuggestions/highlighting.
Setting it to anything else will enable it (which also
means this remains enabled by default).
This commit is contained in:
Fabian Homborg
2021-10-21 16:54:24 +02:00
parent d81f817f70
commit 86b8cc2097
3 changed files with 25 additions and 1 deletions

View File

@@ -603,7 +603,7 @@ struct layout_data_t {
class reader_data_t : public std::enable_shared_from_this<reader_data_t> {
public:
/// Configuration for the reader.
const reader_config_t conf;
reader_config_t conf;
/// The parser being used.
std::shared_ptr<parser_t> parser_ref;
/// String containing the whole current commandline.
@@ -2612,6 +2612,18 @@ void reader_change_history(const wcstring &name) {
}
}
void reader_set_autosuggestion_enabled(bool enable) {
// We don't need to _change_ if we're not initialized yet.
reader_data_t *data = current_data_or_null();
if (data) {
if (data->conf.autosuggest_ok != enable) {
data->conf.autosuggest_ok = enable;
data->force_exec_prompt_and_repaint = true;
data->inputter.queue_char(readline_cmd_t::repaint);
}
}
}
/// Add a new reader to the reader stack.
/// \return a shared pointer to it.
static std::shared_ptr<reader_data_t> reader_push_ret(parser_t &parser,