diff --git a/doc/pages/changelog.asciidoc b/doc/pages/changelog.asciidoc index e8331d13..b5f937e3 100644 --- a/doc/pages/changelog.asciidoc +++ b/doc/pages/changelog.asciidoc @@ -5,6 +5,8 @@ released versions. == Development version +* `%val{window_range}` elements are now emitted as different strings + * `+` only duplicates identical selections a single time to avoid surprising and slow exponential growth in the number of selections. diff --git a/src/input_handler.cc b/src/input_handler.cc index 5b60026e..a5a25413 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -1115,32 +1115,32 @@ private: const String& line = m_line_editor.line(); m_completions = completer(context(), flags, line, line.byte_count_to(m_line_editor.cursor_pos())); + if (not context().has_client()) + return; + + if (m_completions.candidates.empty()) + return context().client().menu_hide(); + + Vector items; + for (auto& candidate : m_completions.candidates) + items.push_back({ candidate, {} }); + + const auto menu_style = (m_flags & PromptFlags::Search) ? MenuStyle::Search : MenuStyle::Prompt; + context().client().menu_show(items, {}, menu_style); + const bool menu = (bool)(m_completions.flags & Completions::Flags::Menu); - if (context().has_client()) + if (menu) + context().client().menu_select(0); + + auto prefix = line.substr(m_completions.start, m_completions.end - m_completions.start); + if (not menu and not contains(m_completions.candidates, prefix)) { - if (m_completions.candidates.empty()) - return context().client().menu_hide(); - - Vector items; - for (auto& candidate : m_completions.candidates) - items.push_back({ candidate, {} }); - - const auto menu_style = (m_flags & PromptFlags::Search) ? MenuStyle::Search : MenuStyle::Prompt; - context().client().menu_show(items, {}, menu_style); - - if (menu) - context().client().menu_select(0); - - auto prefix = line.substr(m_completions.start, m_completions.end - m_completions.start); - if (not menu and not contains(m_completions.candidates, prefix)) - { - m_current_completion = m_completions.candidates.size(); - m_completions.candidates.push_back(prefix.str()); - m_prefix_in_completions = true; - } - else - m_prefix_in_completions = false; + m_current_completion = m_completions.candidates.size(); + m_completions.candidates.push_back(prefix.str()); + m_prefix_in_completions = true; } + else + m_prefix_in_completions = false; } catch (runtime_error&) {} } diff --git a/src/main.cc b/src/main.cc index 1d5b8dd7..bc12f335 100644 --- a/src/main.cc +++ b/src/main.cc @@ -46,6 +46,7 @@ struct { StringView notes; } constexpr version_notes[] = { { 0, + "» {+b}%val{window_range}{} is now emitted as separate strings\n" "» {+b}+{} only duplicates identical selections a single time\n" "» {+u}daemonize-session{} command\n" }, { @@ -387,8 +388,8 @@ static const EnvVarDesc builtin_env_vars[] = { { [](StringView name, const Context& context) -> Vector { const auto& setup = context.window().last_display_setup(); - return {format("{} {} {} {}", setup.first_line, setup.first_column, - setup.line_count, 0)}; + return {to_string(setup.first_line), to_string(setup.first_column), + to_string(setup.line_count), to_string(0)}; } }, { "history", false,