QScintilla/TypingCompleters/CompleterPython.py

changeset 6247
5c677a7f7d51
parent 6048
82ad8ec9548c
child 6645
ad476851d7e0
equal deleted inserted replaced
6246:fe07a9f16f23 6247:5c677a7f7d51
210 elif char == '\n': 210 elif char == '\n':
211 if self.__indentBrace: 211 if self.__indentBrace:
212 txt = self.editor.text(line - 1) 212 txt = self.editor.text(line - 1)
213 if re.search(":\r?\n", txt) is None: 213 if re.search(":\r?\n", txt) is None:
214 openCount = len(re.findall("[({[]", txt)) 214 openCount = len(re.findall("[({[]", txt))
215 closeCount = len(re.findall("[)}\]]", txt)) 215 closeCount = len(re.findall(r"[)}\]]", txt))
216 if openCount > closeCount: 216 if openCount > closeCount:
217 openCount = 0 217 openCount = 0
218 closeCount = 0 218 closeCount = 0
219 openList = list(re.finditer("[({[]", txt)) 219 openList = list(re.finditer("[({[]", txt))
220 index = len(openList) - 1 220 index = len(openList) - 1
221 while index > -1 and openCount == closeCount: 221 while index > -1 and openCount == closeCount:
222 lastOpenIndex = openList[index].start() 222 lastOpenIndex = openList[index].start()
223 txt2 = txt[lastOpenIndex:] 223 txt2 = txt[lastOpenIndex:]
224 openCount = len(re.findall("[({[]", txt2)) 224 openCount = len(re.findall("[({[]", txt2))
225 closeCount = len(re.findall("[)}\]]", txt2)) 225 closeCount = len(re.findall(r"[)}\]]", txt2))
226 index -= 1 226 index -= 1
227 if openCount > closeCount and lastOpenIndex > col: 227 if openCount > closeCount and lastOpenIndex > col:
228 self.editor.insert(' ' * (lastOpenIndex - col + 1)) 228 self.editor.insert(' ' * (lastOpenIndex - col + 1))
229 self.editor.setCursorPosition( 229 self.editor.setCursorPosition(
230 line, lastOpenIndex + 1) 230 line, lastOpenIndex + 1)

eric ide

mercurial