diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2014-11-04 23:51:41 +0000 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2014-11-04 23:51:41 +0000 |
| commit | 4c3056a05e502f73f29178bdee97e5e27608229c (patch) | |
| tree | 0d1867c463a804776e367661741408d59cbde006 /src/insert_completer.cc | |
| parent | c8ea2e78f9a926268836d5a1830cf7f39a1943d8 (diff) | |
Fix bug in insert completer deregistering
The context options might change, as the context might have a different
window/buffer from the one at creation. So we need to store the correct
option manager rather than ask the context for it.
Diffstat (limited to 'src/insert_completer.cc')
| -rw-r--r-- | src/insert_completer.cc | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/insert_completer.cc b/src/insert_completer.cc index 43206008..b217f304 100644 --- a/src/insert_completer.cc +++ b/src/insert_completer.cc @@ -217,14 +217,14 @@ InsertCompletion complete_line(const Buffer& buffer, ByteCoord cursor_pos) } InsertCompleter::InsertCompleter(const Context& context) - : m_context(context) + : m_context(context), m_options(context.options()) { - context.options().register_watcher(*this); + m_options.register_watcher(*this); } InsertCompleter::~InsertCompleter() { - m_context.options().unregister_watcher(*this); + m_options.unregister_watcher(*this); } void InsertCompleter::select(int offset) @@ -321,19 +321,19 @@ bool InsertCompleter::setup_ifn() using namespace std::placeholders; if (not m_completions.is_valid()) { - auto& completers = m_context.options()["completers"].get<InsertCompleterDescList>(); + auto& completers = m_options["completers"].get<InsertCompleterDescList>(); for (auto& completer : completers) { if (completer.mode == InsertCompleterDesc::Filename and try_complete([this](const Buffer& buffer, ByteCoord cursor_pos) { return complete_filename<true>(buffer, cursor_pos, - m_context.options()); + m_options); })) return true; if (completer.mode == InsertCompleterDesc::Option and try_complete([&,this](const Buffer& buffer, ByteCoord cursor_pos) { return complete_option(buffer, cursor_pos, - m_context.options(), *completer.param); + m_options, *completer.param); })) return true; if (completer.mode == InsertCompleterDesc::Word and @@ -358,7 +358,7 @@ void InsertCompleter::menu_show() return; CharCoord menu_pos = m_context.window().display_position(m_completions.begin); - const CharCount tabstop = m_context.options()["tabstop"].get<int>(); + const CharCount tabstop = m_options["tabstop"].get<int>(); const CharCount column = get_column(m_context.buffer(), tabstop, m_completions.begin); std::vector<String> menu_entries; @@ -374,7 +374,7 @@ void InsertCompleter::menu_show() void InsertCompleter::on_option_changed(const Option& opt) { - auto& completers = m_context.options()["completers"].get<InsertCompleterDescList>(); + auto& completers = m_options["completers"].get<InsertCompleterDescList>(); std::vector<StringView> option_names; for (auto& completer : completers) { @@ -416,7 +416,7 @@ bool InsertCompleter::try_complete(CompleteFunc complete_func) void InsertCompleter::explicit_file_complete() { try_complete([this](const Buffer& buffer, ByteCoord cursor_pos) { - return complete_filename<false>(buffer, cursor_pos, m_context.options()); + return complete_filename<false>(buffer, cursor_pos, m_options); }); } |
