]> git.lyx.org Git - features.git/commitdiff
Fix completion in math when inline completion was not yet shown (take 2)
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 16 Mar 2023 10:54:33 +0000 (11:54 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 16 Mar 2023 10:58:49 +0000 (11:58 +0100)
Better version of b4211ef2: we handle the case of a unique completion early.

Fixes bug #12674.

src/frontends/qt/GuiCompleter.cpp

index 2aee43691231e0b243f28e95f38714a462cbfcfc..01ae3ccec8c120e3f95b0ac1c9de11675861e4b9 100644 (file)
@@ -688,9 +688,10 @@ void GuiCompleter::tab()
        // If completion is active, at least complete by one character
        docstring prefix = cur.inset().completionPrefix(cur);
        docstring completion = qstring_to_ucs4(currentCompletion());
-       if (completion.size() <= prefix.size()) {
+       if (uniqueCompletionAvailable() || completion.size() <= prefix.size()) {
                // 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
                hidePopup();