src/eric7/QScintilla/Editor.py

branch
eric7
changeset 10343
d7d52b0b4448
parent 10341
3fdffd9cc21d
child 10344
2f2e3294186d
--- a/src/eric7/QScintilla/Editor.py	Mon Nov 27 08:37:30 2023 +0100
+++ b/src/eric7/QScintilla/Editor.py	Mon Nov 27 09:57:04 2023 +0100
@@ -5579,26 +5579,33 @@
             if len(lst) > 1:
                 txt = lst[0]
 
-            self.beginUndoAction()
             if Preferences.getEditor("AutoCompletionReplaceWord"):
+                self.beginUndoAction()
                 self.selectCurrentWord()
                 self.removeSelectedText()
                 line, col = self.getCursorPosition()
+                self.insert(txt)
+                self.endUndoAction()
             else:
                 line, col = self.getCursorPosition()
                 wLeft = self.getWordLeft(line, col)
-                if not txt.startswith(wLeft):
-                    self.selectCurrentWord()
-                    self.removeSelectedText()
-                    line, col = self.getCursorPosition()
-                elif wLeft:
-                    txt = txt[len(wLeft) :]
-
-                if txt and txt[0] in "'\"":
-                    # New in jedi 0.16: AC of dict keys
-                    txt = txt[1:]
-            self.insert(txt)
-            self.endUndoAction()
+                if wLeft:
+                    self.beginUndoAction()
+                    if txt.startswith(wLeft):
+                        txt = txt[len(wLeft) :]
+                    else:
+                        self.selectCurrentWord()
+                        self.removeSelectedText()
+                        line, col = self.getCursorPosition()
+
+                    if txt and txt[0] in "'\"":
+                        # New in jedi 0.16: AC of dict keys
+                        txt = txt[1:]
+                    self.insert(txt)
+                    self.endUndoAction()
+                else:
+                    return
+
             self.setCursorPosition(line, col + len(txt))
 
         # template completions

eric ide

mercurial