Fixed new line indenting logic 2

This commit is contained in:
itdominator 2023-10-31 00:55:11 -05:00
parent a449ca6807
commit 0f469ee639

View File

@ -94,19 +94,18 @@ class MarkEventsMixin:
self.end_user_action(buffer) self.end_user_action(buffer)
def _new_line_on_multi_line_markers(self, buffer): def _new_line_on_multi_line_markers(self, buffer):
self.freeze_multi_line_insert = True iter = buffer.get_iter_at_mark( buffer.get_insert() )
iter = buffer.get_iter_at_mark( buffer.get_insert() )
self._base_indent(buffer, iter) self._base_indent(buffer, iter)
self.insert_indent_handler(buffer, iter) self.insert_indent_handler(buffer, iter)
for mark in self._multi_insert_marks: for mark in self._multi_insert_marks:
iter = buffer.get_iter_at_mark(mark) iter = buffer.get_iter_at_mark(mark)
iter_copy = iter.copy()
self._base_indent(buffer, iter) self._base_indent(buffer, iter)
self.insert_indent_handler(buffer, iter) self.insert_indent_handler(buffer, iter)
self.freeze_multi_line_insert = False
self.end_user_action(buffer) self.end_user_action(buffer)
def insert_indent_handler(self, buffer, iter = None): def insert_indent_handler(self, buffer, iter = None):
@ -118,17 +117,17 @@ class MarkEventsMixin:
iter_copy.forward_sentence_end() iter_copy.forward_sentence_end()
iter_copy.backward_char() iter_copy.backward_char()
_char = iter_copy.get_char() # Note: Need to compare line nums too because backward_sentence_start
if _char in ["{", ":"]: # and forward_sentence_end can go farther back if just spaces inbetween...
self._indent_deeper(buffer, iter) line_start = iter.get_line()
line_end = iter_copy.get_line()
return True _char = iter_copy.get_char()
if _char in ["{", ":"] and (line_start - line_end) == 1:
self._indent_deeper(buffer, iter)
def _base_indent(self, buffer, iter, iter_copy = None): def _base_indent(self, buffer, iter):
if not iter_copy: line_num = iter.get_line()
iter_copy = iter.copy()
line_num = iter_copy.get_line()
iter_copy = buffer.get_iter_at_line(line_num) iter_copy = buffer.get_iter_at_line(line_num)
spaces = "" spaces = ""