@Alan-Kilborn
Note, I do have autoindent disabled in order to make this work.
Because I know you are doing python, I haven’t refactored anything,
but I guess it’s mostly getting rid of self to make this work in a non-class way.
Concerning the todo, no, I haven’t looked at it since then.
def __init__(self):
self.excluded_styles= [1, 3, 4, 6, 7, 12, 16, 17, 18, 19]
def on_modified(self, args):
# TODO: text == \r even if \r\n is assumed, but length is 2, is this a bug?? Or am I doing something wrong?
if args['modificationType'] & 0x100000 == 0x100000 and args['text'] in ['\r','\n']:
text = '\r\n' if args['length'] == 2 else args['text']
self._indent(args['position'], text)
def _indent(self, position, text):
if self.is_python and self.auto_indent:
indent = editor.getLineIndentation(editor.lineFromPosition(position))
if (editor.getCharAt(position-1) == 58 and # 58 == :
editor.getStyleAt(position-1) not in self.excluded_styles):
tabwidth = editor.getTabWidth()
text += ' '*(indent//tabwidth+1)*tabwidth
else:
text += ' '*indent
editor.changeInsertion(text)