generated from itdominator/Python-With-Gtk-Template
Fixed new line indenting logic 2
This commit is contained in:
parent
a449ca6807
commit
0f469ee639
|
@ -94,19 +94,18 @@ class MarkEventsMixin:
|
|||
self.end_user_action(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.insert_indent_handler(buffer, iter)
|
||||
|
||||
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.insert_indent_handler(buffer, iter)
|
||||
|
||||
self.freeze_multi_line_insert = False
|
||||
self.end_user_action(buffer)
|
||||
|
||||
def insert_indent_handler(self, buffer, iter = None):
|
||||
|
@ -118,17 +117,17 @@ class MarkEventsMixin:
|
|||
iter_copy.forward_sentence_end()
|
||||
iter_copy.backward_char()
|
||||
|
||||
_char = iter_copy.get_char()
|
||||
if _char in ["{", ":"]:
|
||||
self._indent_deeper(buffer, iter)
|
||||
# Note: Need to compare line nums too because backward_sentence_start
|
||||
# and forward_sentence_end can go farther back if just spaces inbetween...
|
||||
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):
|
||||
if not iter_copy:
|
||||
iter_copy = iter.copy()
|
||||
|
||||
line_num = iter_copy.get_line()
|
||||
def _base_indent(self, buffer, iter):
|
||||
line_num = iter.get_line()
|
||||
iter_copy = buffer.get_iter_at_line(line_num)
|
||||
|
||||
spaces = ""
|
||||
|
|
Loading…
Reference in New Issue