Coding style

- lines too long.
- Unnecessary 'if'.
This commit is contained in:
Andrew Hamilton 2022-05-13 14:29:26 +10:00
parent 8028f035e2
commit 324e3a8c68
2 changed files with 11 additions and 10 deletions

View file

@ -344,7 +344,7 @@ class DiffEditor:
continue continue
color = colors[color_index % len(colors)] color = colors[color_index % len(colors)]
left_y = left_start - left_scroll + self.left_editor.parts_height + 1 # 1 for header left_y = left_start - left_scroll + self.left_editor.parts_height + 1 # 1 for header
right_y = right_start - right_scroll + self.right_editor.parts_height + 1 # 1 for header right_y = right_start - right_scroll + self.right_editor.parts_height + 1
draw_connector(columns, color, left_y, right_y) draw_connector(columns, color, left_y, right_y)
for y in [left_y, right_y]: for y in [left_y, right_y]:
if y <= 0: if y <= 0:

View file

@ -98,14 +98,14 @@ class Text:
return self.lines[line_index] return self.lines[line_index]
def __setitem__(self, key, value): def __setitem__(self, key, value):
if type(key) == int: if type(key) == int and \
if len(expand_str(self.lines[key])) != self.max_line_length: len(expand_str(self.lines[key])) != self.max_line_length:
self.lines[key] = value self.lines[key] = value
self._new_line(value) self._new_line(value)
return else:
self.lines[key] = value self.lines[key] = value
with contextlib.suppress(AttributeError): with contextlib.suppress(AttributeError):
del self.max_line_length del self.max_line_length
def insert(self, index, line): def insert(self, index, line):
self.lines.insert(index, line) self.lines.insert(index, line)
@ -862,7 +862,8 @@ class Editor:
change_marker = "*" if is_changed else "" change_marker = "*" if is_changed else ""
cursor_position = termstr.TermStr( cursor_position = termstr.TermStr(
f"Line {cursor_y+1} Column {cursor_x+1:<3}").fg_color(termstr.Color.grey_100) f"Line {cursor_y+1} Column {cursor_x+1:<3}").fg_color(termstr.Color.grey_100)
path_part = (lscolors.path_colored(path) + change_marker).ljust(width - len(cursor_position) - 2) path_colored = lscolors.path_colored(path) + change_marker
path_part = path_colored.ljust(width - len(cursor_position) - 2)
header = " " + path_part + cursor_position + " " header = " " + path_part + cursor_position + " "
return termstr.TermStr(header).bg_color(termstr.Color.grey_50) return termstr.TermStr(header).bg_color(termstr.Color.grey_50)