--- a/eric6/QScintilla/TypingCompleters/CompleterYaml.py Sun Apr 11 16:53:48 2021 +0200 +++ b/eric6/QScintilla/TypingCompleters/CompleterYaml.py Sun Apr 11 18:45:10 2021 +0200 @@ -77,31 +77,27 @@ # open curly brace # insert closing brace - if char == '{': - if self.__insertClosingBrace: - self.editor.insert('}') + if char == '{' and self.__insertClosingBrace: + self.editor.insert('}') # open bracket # insert closing bracket - elif char == '[': - if self.__insertClosingBrace: - self.editor.insert(']') + elif char == '[' and self.__insertClosingBrace: + self.editor.insert(']') # closing parenthesis # skip matching closing parenthesis elif char in ['}', ']']: txt = self.editor.text(line) - if col < len(txt) and char == txt[col]: - if self.__skipBrace: - self.editor.setSelection(line, col, line, col + 1) - self.editor.removeSelectedText() + if col < len(txt) and char == txt[col] and self.__skipBrace: + self.editor.setSelection(line, col, line, col + 1) + self.editor.removeSelectedText() # dash # insert blank - elif char == '-': - if self.__insertBlankDash: - self.editor.insert(' ') - self.editor.setCursorPosition(line, col + 1) + elif char == '-' and self.__insertBlankDash: + self.editor.insert(' ') + self.editor.setCursorPosition(line, col + 1) # colon # 1. skip colon if not last character @@ -112,59 +108,53 @@ if self.__colonDetection: self.editor.setSelection(line, col, line, col + 1) self.editor.removeSelectedText() - elif self.__insertBlankColon: - if col == len(text.rstrip()): - self.editor.insert(' ') - self.editor.setCursorPosition(line, col + 1) - - # question mark - # insert blank - elif char == '?': - if self.__insertBlankQuestion: + elif self.__insertBlankColon and col == len(text.rstrip()): self.editor.insert(' ') self.editor.setCursorPosition(line, col + 1) + # question mark + # insert blank + elif char == '?' and self.__insertBlankQuestion: + self.editor.insert(' ') + self.editor.setCursorPosition(line, col + 1) + # comma # insert blank - elif char == ',': - if self.__insertBlankComma: - self.editor.insert(' ') - self.editor.setCursorPosition(line, col + 1) + elif char == ',' and self.__insertBlankComma: + self.editor.insert(' ') + self.editor.setCursorPosition(line, col + 1) # double quote # insert double quote - elif char == '"': - if self.__insertQuote: - self.editor.insert('"') + elif char == '"' and self.__insertQuote: + self.editor.insert('"') # quote # insert quote - elif char == "'": - if self.__insertQuote: - self.editor.insert("'") + elif char == "'" and self.__insertQuote: + self.editor.insert("'") # new line # indent after line ending with ':' - elif char == '\n': - if self.__autoIndentation: - txt = self.editor.text(line - 1) - match = re.search( - "(?:\||\|-|\|\+|>|>-|>\+|-|:)(\s*)\r?\n", - # __IGNORE_WARNING_W605__ - txt) - if match is not None: - startBlanks = match.start(1) - endBlanks = match.end(1) - if startBlanks != -1 and startBlanks != endBlanks: - # previous line ends with whitespace, e.g. caused by - # blank insertion above - self.editor.setSelection(line - 1, startBlanks, - line - 1, endBlanks) - self.editor.removeSelectedText() - - self.editor.indent(line) - self.editor.setCursorPosition(line, 0) - self.editor.editorCommand(QsciScintilla.SCI_VCHOME) + elif char == '\n' and self.__autoIndentation: + txt = self.editor.text(line - 1) + match = re.search( + "(?:\||\|-|\|\+|>|>-|>\+|-|:)(\s*)\r?\n", + # __IGNORE_WARNING_W605__ + txt) + if match is not None: + startBlanks = match.start(1) + endBlanks = match.end(1) + if startBlanks != -1 and startBlanks != endBlanks: + # previous line ends with whitespace, e.g. caused by + # blank insertion above + self.editor.setSelection(line - 1, startBlanks, + line - 1, endBlanks) + self.editor.removeSelectedText() + + self.editor.indent(line) + self.editor.setCursorPosition(line, 0) + self.editor.editorCommand(QsciScintilla.SCI_VCHOME) def __inComment(self, line, col): """