Fix completion in math when inline completion was not yet shown (take 2)

Better version of b4211ef2: we handle the case of a unique completion early.

Fixes bug #12674.
This commit is contained in:
Jean-Marc Lasgouttes 2023-03-16 11:54:33 +01:00
parent fb1c4494ea
commit 98b5a16793

View File

@ -688,9 +688,10 @@ void GuiCompleter::tab()
// If completion is active, at least complete by one character // If completion is active, at least complete by one character
docstring prefix = cur.inset().completionPrefix(cur); docstring prefix = cur.inset().completionPrefix(cur);
docstring completion = qstring_to_ucs4(currentCompletion()); docstring completion = qstring_to_ucs4(currentCompletion());
if (completion.size() <= prefix.size()) { if (uniqueCompletionAvailable() || completion.size() <= prefix.size()) {
// finalize completion // finalize completion
cur.inset().insertCompletion(cur, docstring(), true); docstring const postfix = completion.substr(min(completion.size(), prefix.size()));
cur.inset().insertCompletion(cur, postfix, true);
// hide popup and inline completion // hide popup and inline completion
hidePopup(); hidePopup();