Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _(event):
text = event.current_buffer.document.text_before_cursor
textList = text.split("\n")
if len(textList) >= 2:
m = re.match(r"^\s*$", textList[-1])
if m:
current_indentation = m.group(0)
previous_indentation = re.match(r"^\s*", textList[-2]).group(0)
tab_size = settings.tab_size
if len(current_indentation) >= settings.tab_size and \
current_indentation == previous_indentation:
event.current_buffer.delete_before_cursor(tab_size)
event.current_buffer.insert_text(event.data)
def _(event):
text = event.current_buffer.document.text_before_cursor
textList = text.split("\n")
if len(textList) >= 2:
m = re.match(r"^\s*$", textList[-1])
if m:
current_indentation = m.group(0)
previous_indentation = re.match(r"^\s*", textList[-2]).group(0)
tab_size = settings.tab_size
if len(current_indentation) >= settings.tab_size and \
current_indentation == previous_indentation:
event.current_buffer.delete_before_cursor(tab_size)
event.current_buffer.insert_text(event.data)
def _(event):
tab_size = settings.tab_size
buf = event.current_buffer
leading_spaces = len(buf.document.text_before_cursor)
buf.delete_before_cursor(min(tab_size, leading_spaces))
def _(event):
copy_margin = not in_paste_mode() and settings.auto_indentation
event.current_buffer.newline(copy_margin=copy_margin)
if settings.auto_indentation:
tab_size = settings.tab_size
event.current_buffer.insert_text(" " * tab_size)
event.current_buffer.insert_text("\n")
event.current_buffer.cursor_position -= 1