Sat, 24 Oct 2020 11:44:39 +0200
CompleterPython: optimized the handling of chained insertions into one undo group.
eric6/QScintilla/TypingCompleters/CompleterPython.py | file | annotate | diff | comparison | revisions |
--- a/eric6/QScintilla/TypingCompleters/CompleterPython.py Fri Oct 23 20:01:22 2020 +0200 +++ b/eric6/QScintilla/TypingCompleters/CompleterPython.py Sat Oct 24 11:44:39 2020 +0200 @@ -111,6 +111,7 @@ # insert closing parenthesis and self if char == '(': txt = self.editor.text(line)[:col] + self.editor.beginUndoAction() if ( self.__insertSelf and self.__defRX.fullmatch(txt) is not None @@ -132,6 +133,7 @@ self.editor.insert('):') else: self.editor.insert(')') + self.editor.endUndoAction() # closing parenthesis # skip matching closing parenthesis @@ -148,12 +150,14 @@ elif char == ' ': txt = self.editor.text(line)[:col] if self.__insertImport and self.__importRX.fullmatch(txt): + self.editor.beginUndoAction() if self.__importBraceType: self.editor.insert('import ()') self.editor.setCursorPosition(line, col + 8) else: self.editor.insert('import ') self.editor.setCursorPosition(line, col + 7) + self.editor.endUndoAction() elif self.__dedentElse and self.__elifRX.fullmatch(txt): self.__dedentToIf() elif self.__dedentExcept and self.__exceptRX.fullmatch(txt): @@ -215,6 +219,7 @@ if self.__indentBrace: txt = self.editor.text(line - 1) if re.search(":\r?\n", txt) is None: + self.editor.beginUndoAction() stxt = txt.strip() if stxt and stxt[-1] in ("(", "[", "{"): # indent one more level @@ -240,7 +245,8 @@ ' ' * (lastOpenIndex - col + 1)) self.editor.setCursorPosition( line, lastOpenIndex + 1) - + self.editor.endUndoAction() + def __dedentToIf(self): """ Private method to dedent the last line to the last if statement with