diff -r 7652b925c25e -r af71f34a0cfb QScintilla/Editor.py --- a/QScintilla/Editor.py Sun May 27 11:32:01 2018 +0200 +++ b/QScintilla/Editor.py Sun May 27 11:34:18 2018 +0200 @@ -410,7 +410,8 @@ self.__acWatchdog.timeout.connect(self.autoCompleteQScintilla) self.userListActivated.connect(self.__completionListSelected) - self.SCN_CHARADDED.connect(self.__charAddedPermanent) + self.SCN_CHARADDED.connect(self.__charAdded) + self.SCN_AUTOCCANCELLED.connect(self.__autocompletionCancelled) self.__completionListHookFunctions = {} self.__completionListAsyncHookFunctions = {} @@ -4420,6 +4421,7 @@ Preferences.getEditor("AutoCompletionCaseSensitivity")) self.setAutoCompletionReplaceWord( Preferences.getEditor("AutoCompletionReplaceWord")) + self.setAutoCompletionThreshold(0) try: self.setAutoCompletionUseSingle( Preferences.getEditor("AutoCompletionShowSingle")) @@ -4433,16 +4435,6 @@ self.setAutoCompletionSource(QsciScintilla.AcsAPIs) else: self.setAutoCompletionSource(QsciScintilla.AcsAll) - if Preferences.getEditor("AutoCompletionEnabled"): - if not self.__completionListHookFunctions and \ - not self.__completionListAsyncHookFunctions: - self.setAutoCompletionThreshold( - Preferences.getEditor("AutoCompletionThreshold")) - else: - self.setAutoCompletionThreshold(0) - else: - self.setAutoCompletionThreshold(-1) - self.setAutoCompletionSource(QsciScintilla.AcsNone) self.maxLines = Preferences.getEditor("AutoCompletionMaxLines") self.maxChars = Preferences.getEditor("AutoCompletionMaxChars") @@ -4517,8 +4509,6 @@ (boolean) """ if enable: - self.setAutoCompletionThreshold( - Preferences.getEditor("AutoCompletionThreshold")) autoCompletionSource = \ Preferences.getEditor("AutoCompletionSource") if autoCompletionSource == QsciScintilla.AcsDocument: @@ -4527,10 +4517,7 @@ self.setAutoCompletionSource(QsciScintilla.AcsAPIs) else: self.setAutoCompletionSource(QsciScintilla.AcsAll) - else: - self.setAutoCompletionThreshold(-1) - self.setAutoCompletionSource(QsciScintilla.AcsNone) - + def __toggleAutoCompletionEnable(self): """ Private slot to handle the Enable Autocompletion context menu entry. @@ -4550,8 +4537,13 @@ @param charNumber value of the character entered (integer) """ + char = chr(charNumber) + # update code documentation viewer + if char == "(" and \ + Preferences.getDocuViewer("ShowInfoOnOpenParenthesis"): + self.vm.showEditorInfo(self) + if self.isListActive(): - char = chr(charNumber) if self.__isStartChar(char): self.cancelList() self.autoComplete(auto=True, context=True) @@ -4634,13 +4626,6 @@ .format(key)) return - if not self.__completionListHookFunctions and \ - not self.__completionListAsyncHookFunctions: - if self.autoCompletionThreshold() > 0: - self.setAutoCompletionThreshold(0) - self.SCN_CHARADDED.connect(self.__charAdded) - self.SCN_AUTOCCANCELLED.connect(self.__autocompletionCancelled) - if asynchroneous: self.__completionListAsyncHookFunctions[key] = func else: @@ -4658,14 +4643,6 @@ del self.__completionListHookFunctions[key] elif key in self.__completionListAsyncHookFunctions: del self.__completionListAsyncHookFunctions[key] - - if not self.__completionListHookFunctions and \ - not self.__completionListAsyncHookFunctions: - self.SCN_CHARADDED.disconnect(self.__charAdded) - self.SCN_AUTOCCANCELLED.disconnect(self.__autocompletionCancelled) - if self.autoCompletionThreshold() == 0: - self.setAutoCompletionThreshold( - Preferences.getEditor("AutoCompletionThreshold")) def getCompletionListHook(self, key): """ @@ -4687,7 +4664,7 @@ (boolean) @keyparam context flag indicating to complete a context (boolean) """ - if auto and self.autoCompletionThreshold() == -1: + if auto and not Preferences.getEditor("AutoCompletionEnabled"): # auto-completion is disabled return @@ -5064,20 +5041,6 @@ ## Methods needed by the code documentation viewer ################################################################# - def __charAddedPermanent(self, charNumber): - """ - Private slot called to handle the user entering a character. - - Note: This slot is always connected independent of the auto-completion - and calltips handling __charAdded() slot. - - @param charNumber value of the character entered (integer) - """ - char = chr(charNumber) - if char == "(" and \ - Preferences.getDocuViewer("ShowInfoOnOpenParenthesis"): - self.vm.showEditorInfo(self) - def __showCodeInfo(self): """ Private slot to handle the context menu action to show code info.