Only auto-insert completion when at the end of the line

Auto inserting in the middle is annoying more often than not.
This commit is contained in:
Maxime Coste 2023-07-04 17:15:33 +10:00
parent 661d1a0905
commit 53fed4b8b9

View File

@ -815,9 +815,10 @@ public:
const bool has_completions = not m_completions.candidates.empty(); const bool has_completions = not m_completions.candidates.empty();
const bool completion_selected = m_current_completion != -1; const bool completion_selected = m_current_completion != -1;
const bool text_entered = m_completions.start != line.byte_count_to(m_line_editor.cursor_pos()); const bool text_entered = m_completions.start != line.byte_count_to(m_line_editor.cursor_pos());
const bool at_end = line.byte_count_to(m_line_editor.cursor_pos()) == line.length();
return (m_completions.flags & Completions::Flags::Menu) and return (m_completions.flags & Completions::Flags::Menu) and
has_completions and has_completions and
not completion_selected and not completion_selected and at_end and
(not (m_completions.flags & Completions::Flags::NoEmpty) or text_entered); (not (m_completions.flags & Completions::Flags::NoEmpty) or text_entered);
}; };