[LyX/master] Fix completion in math when inline completion was not yet shown (take 2)

Jean-Marc Lasgouttes lasgouttes at lyx.org
Thu Mar 16 09:55:32 UTC 2023


commit 98b5a167930a5dc1e3a9a07ff0afb3dba58bb515
Author: Jean-Marc Lasgouttes <lasgouttes at lyx.org>
Date:   Thu Mar 16 11:54:33 2023 +0100

    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.
---
 src/frontends/qt/GuiCompleter.cpp |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/frontends/qt/GuiCompleter.cpp b/src/frontends/qt/GuiCompleter.cpp
index 2aee436..01ae3cc 100644
--- a/src/frontends/qt/GuiCompleter.cpp
+++ b/src/frontends/qt/GuiCompleter.cpp
@@ -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();


More information about the lyx-cvs mailing list