generated from itdominator/Python-With-Gtk-Template
Fixed new line indenting logic 2
This commit is contained in:
parent
a449ca6807
commit
0f469ee639
|
@ -94,8 +94,6 @@ 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)
|
||||||
|
@ -103,10 +101,11 @@ class MarkEventsMixin:
|
||||||
|
|
||||||
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()
|
||||||
|
|
||||||
|
# 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()
|
||||||
|
|
||||||
_char = iter_copy.get_char()
|
_char = iter_copy.get_char()
|
||||||
if _char in ["{", ":"]:
|
if _char in ["{", ":"] and (line_start - line_end) == 1:
|
||||||
self._indent_deeper(buffer, iter)
|
self._indent_deeper(buffer, iter)
|
||||||
|
|
||||||
return True
|
def _base_indent(self, buffer, iter):
|
||||||
|
line_num = iter.get_line()
|
||||||
def _base_indent(self, buffer, iter, iter_copy = None):
|
|
||||||
if not iter_copy:
|
|
||||||
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 = ""
|
||||||
|
|
Loading…
Reference in New Issue