Remove complete_prefix option and behaviour

Now that we use subsequence based completion almost everywhere,
completing the common prefix does not make sense anymore.
This commit is contained in:
Maxime Coste 2016-03-07 20:17:41 +00:00
parent 7202ff373e
commit 52525a156f
4 changed files with 6 additions and 50 deletions

View File

@ -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

View File

@ -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

View File

@ -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<bool>())
{
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 (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;
}
const String& completion = candidates[m_current_completion];
if (context().has_client())

View File

@ -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);