From 52525a156ff2a9f5c8c6fbb2e933ec412afb4728 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 7 Mar 2016 20:17:41 +0000 Subject: [PATCH] Remove complete_prefix option and behaviour Now that we use subsequence based completion almost everywhere, completing the common prefix does not make sense anymore. --- README.asciidoc | 2 -- doc/manpages/options.asciidoc | 4 --- src/input_handler.cc | 47 +++++------------------------------ src/main.cc | 3 --- 4 files changed, 6 insertions(+), 50 deletions(-) diff --git a/README.asciidoc b/README.asciidoc index ff1abe27..14a2c8bf 100644 --- a/README.asciidoc +++ b/README.asciidoc @@ -813,8 +813,6 @@ Some options are built in Kakoune, and can be used to control it's behaviour: writing a buffer, this is autodetected on load. * `BOM` _enum(none|utf8)_: define if the file should be written with an unicode byte order mark. - * `complete_prefix` _bool_: when completing in command line, and multiple - candidates exist, enable completion with common prefix. * `incsearch` _bool_: execute search as it is typed * `aligntab` _bool_: use tabs for alignment command * `autoinfo` _flags(command|onkey|normal)_: display automatic information diff --git a/doc/manpages/options.asciidoc b/doc/manpages/options.asciidoc index 53fd6802..7edd4f8e 100644 --- a/doc/manpages/options.asciidoc +++ b/doc/manpages/options.asciidoc @@ -66,10 +66,6 @@ Builtin options *BOM* 'enum(none|utf8)':: define if the file should be written with an unicode byte order mark -*complete_prefix* 'bool':: - when completing in command line, and multiple candidates exist, - enable completion with common prefix - *incsearch* 'bool':: execute search as it is typed diff --git a/src/input_handler.cc b/src/input_handler.cc index 1f307f67..3871398d 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -762,51 +762,16 @@ public: const bool reverse = (key == Key::BackTab); CandidateList& candidates = m_completions.candidates; // first try, we need to ask our completer for completions - bool updated_completions = false; if (candidates.empty()) - { refresh_completions(CompletionFlags::None); - if (candidates.empty()) - return; - updated_completions = true; - } - bool did_prefix = false; - if (m_current_completion == -1 and - context().options()["complete_prefix"].get()) - { - const String& line = m_line_editor.line(); - CandidateList& candidates = m_completions.candidates; - String prefix = common_prefix(candidates); - if (m_completions.end - m_completions.start > prefix.length()) - prefix = line.substr(m_completions.start, - m_completions.end - m_completions.start).str(); + if (candidates.empty()) + return; - if (not prefix.empty()) - { - auto it = find(candidates, prefix); - if (it == candidates.end()) - { - m_current_completion = candidates.size(); - candidates.push_back(prefix); - } - else - m_current_completion = it - candidates.begin(); - - CharCount start = line.char_count_to(m_completions.start); - // When we just updated completions, select the common - // prefix even if it was the currently entered text. - did_prefix = updated_completions or - prefix != line.substr(start, m_line_editor.cursor_pos() - start); - } - } - if (not did_prefix) - { - if (not reverse and ++m_current_completion >= candidates.size()) - m_current_completion = 0; - else if (reverse and --m_current_completion < 0) - m_current_completion = candidates.size()-1; - } + if (not reverse and ++m_current_completion >= candidates.size()) + m_current_completion = 0; + else if (reverse and --m_current_completion < 0) + m_current_completion = candidates.size()-1; const String& completion = candidates[m_current_completion]; if (context().has_client()) diff --git a/src/main.cc b/src/main.cc index 960ba7ec..11f6c11d 100644 --- a/src/main.cc +++ b/src/main.cc @@ -206,9 +206,6 @@ void register_options() reg.declare_option("eolformat", "end of line format: crlf or lf", EolFormat::Lf); reg.declare_option("BOM", "insert a byte order mark when writing buffer (none or utf8)", ByteOrderMark::None); - reg.declare_option("complete_prefix", - "complete up to common prefix in tab completion", - true); reg.declare_option("incsearch", "incrementaly apply search/select/split regex", true);