54 self.__exceptRX = re.compile(r"^[ \t]*except ") |
54 self.__exceptRX = re.compile(r"^[ \t]*except ") |
55 self.__exceptcRX = re.compile(r"^[ \t]*except:") |
55 self.__exceptcRX = re.compile(r"^[ \t]*except:") |
56 |
56 |
57 self.__whileRX = re.compile(r"^[ \t]*while ") |
57 self.__whileRX = re.compile(r"^[ \t]*while ") |
58 self.__forRX = re.compile(r"^[ \t]*(async[ \t]+)?for ") |
58 self.__forRX = re.compile(r"^[ \t]*(async[ \t]+)?for ") |
|
59 |
|
60 self.__trailingBlankRe = re.compile(r"(?:,)(\s*)\r?\n") |
59 |
61 |
60 self.readSettings() |
62 self.readSettings() |
61 |
63 |
62 def readSettings(self): |
64 def readSettings(self): |
63 """ |
65 """ |
198 |
200 |
199 # new line |
201 # new line |
200 # indent to opening brace |
202 # indent to opening brace |
201 elif char == "\n" and self.__indentBrace: |
203 elif char == "\n" and self.__indentBrace: |
202 txt = self.editor.text(line - 1) |
204 txt = self.editor.text(line - 1) |
|
205 if self.__insertBlank and self.__trailingBlankRe.search(txt): |
|
206 match = self.__trailingBlankRe.search(txt) |
|
207 if match is not None: |
|
208 startBlanks = match.start(1) |
|
209 endBlanks = match.end(1) |
|
210 if startBlanks != -1 and startBlanks != endBlanks: |
|
211 # previous line ends with whitespace, e.g. caused by |
|
212 # blank insertion above |
|
213 self.editor.setSelection( |
|
214 line - 1, startBlanks, line - 1, endBlanks |
|
215 ) |
|
216 self.editor.removeSelectedText() |
|
217 # get the line again for next check |
|
218 txt = self.editor.text(line - 1) |
|
219 |
|
220 self.editor.setCursorPosition(line, 0) |
|
221 self.editor.editorCommand(QsciScintilla.SCI_VCHOME) |
|
222 |
203 if re.search(":\r?\n", txt) is None: |
223 if re.search(":\r?\n", txt) is None: |
204 self.editor.beginUndoAction() |
224 self.editor.beginUndoAction() |
205 stxt = txt.strip() |
225 stxt = txt.strip() |
206 if stxt and stxt[-1] in ("(", "[", "{"): |
226 if stxt and stxt[-1] in ("(", "[", "{"): |
207 # indent one more level |
227 # indent one more level |