Merged with changes made by Tobias.

Sat, 23 Feb 2019 16:10:31 +0100

author
Detlev Offenbach <detlev@die-offenbachs.de>
date
Sat, 23 Feb 2019 16:10:31 +0100
changeset 6810
1ccd89be29e3
parent 6807
7e5eba19d86d (current diff)
parent 6809
d1048e6db7f5 (diff)
child 6811
e84fce34c460

Merged with changes made by Tobias.

--- a/QScintilla/Editor.py	Sat Feb 23 16:05:36 2019 +0100
+++ b/QScintilla/Editor.py	Sat Feb 23 16:10:31 2019 +0100
@@ -4675,6 +4675,8 @@
         
         if self.__completionListHookFunctions or \
            self.__completionListAsyncHookFunctions:
+            # Avoid delayed auto-completion after cursor repositioning
+            self.__acText = self.__getAcText()
             if auto and Preferences.getEditor("AutoCompletionTimeout"):
                 self.__acTimer.stop()
                 self.__acContext = context
@@ -4686,6 +4688,25 @@
         elif self.autoCompletionSource() != QsciScintilla.AcsNone:
             self.autoCompleteQScintilla()
     
+    def __getAcText(self):
+        """
+        Private method to get the text from cursor position for autocompleting.
+        
+        @return text left of cursor position
+        @rtype str
+        """
+        line, col = self.getCursorPosition()
+        text = self.text(line)
+        try:
+            if self.__isStartChar(text[col - 1]):
+                acText = self.getWordLeft(line, col - 1) + text[col - 1]
+            else:
+                acText = self.getWordLeft(line, col)
+        except IndexError:
+            acText = ""
+        
+        return acText
+    
     def __autoComplete(self, auto=True, context=None):
         """
         Private method to start auto-completion via plug-ins.
@@ -4695,16 +4716,6 @@
         @keyparam context flag indicating to complete a context
         @type bool or None
         """
-        line, col = self.getCursorPosition()
-        text = self.text(line)
-        try:
-            if self.__isStartChar(text[col - 1]):
-                self.__acText = self.getWordLeft(line, col - 1) + text[col - 1]
-            else:
-                self.__acText = self.getWordLeft(line, col)
-        except IndexError:
-            self.__acText = ""
-        
         self.__acCompletions.clear()
         self.__acCompletionsFinished = 0
         
@@ -4748,8 +4759,11 @@
         @param acText text to be completed
         @type str
         """
+        currentWord = self.__getAcText() or ' '
         # process the list only, if not already obsolete ...
-        if acText != self.__acText:
+        if acText != self.__acText or not self.__acText.endswith(currentWord):
+            # Suppress auto-completion done by QScintilla as fallback
+            self.__acWatchdog.stop()
             return
         
         self.__acCompletions.update(set(completions))
--- a/changelog	Sat Feb 23 16:05:36 2019 +0100
+++ b/changelog	Sat Feb 23 16:10:31 2019 +0100
@@ -5,6 +5,8 @@
 - Conda Interface
   -- added an interface to the conda environmenta nd package management
      (part of the Anaconda Python distribution)
+- Editor
+  -- suppress auto-completions in various circumstances
 - VirtualEnv Manager
   -- extended the environment definition by a flag indicating a remotely
      accessed environment
@@ -28,7 +30,7 @@
   -- show / stop at correct line number if an exception happens in a with
      statement or specific try-except clauses where no breakpoints are set
 - Editor
-  -- added cpability to suppress some markers in the marker map
+  -- added capability to suppress some markers in the marker map
 - Multi Project
   -- added capability to the multi project browser to delete a project
      from disk

eric ide

mercurial