From 324e3a8c68373ad4df740a341ff0d19b36b07eb6 Mon Sep 17 00:00:00 2001 From: Andrew Hamilton Date: Fri, 13 May 2022 14:29:26 +1000 Subject: [PATCH] Coding style - lines too long. - Unnecessary 'if'. --- diff_edit/__init__.py | 2 +- diff_edit/editor.py | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/diff_edit/__init__.py b/diff_edit/__init__.py index 1742080..4789cdf 100755 --- a/diff_edit/__init__.py +++ b/diff_edit/__init__.py @@ -344,7 +344,7 @@ class DiffEditor: continue color = colors[color_index % len(colors)] 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) for y in [left_y, right_y]: if y <= 0: diff --git a/diff_edit/editor.py b/diff_edit/editor.py index dd1d59d..ccb4631 100755 --- a/diff_edit/editor.py +++ b/diff_edit/editor.py @@ -98,14 +98,14 @@ class Text: return self.lines[line_index] def __setitem__(self, key, value): - if type(key) == int: - if len(expand_str(self.lines[key])) != self.max_line_length: - self.lines[key] = value - self._new_line(value) - return - self.lines[key] = value - with contextlib.suppress(AttributeError): - del self.max_line_length + if type(key) == int and \ + len(expand_str(self.lines[key])) != self.max_line_length: + self.lines[key] = value + self._new_line(value) + else: + self.lines[key] = value + with contextlib.suppress(AttributeError): + del self.max_line_length def insert(self, index, line): self.lines.insert(index, line) @@ -862,7 +862,8 @@ class Editor: change_marker = "*" if is_changed else "" cursor_position = termstr.TermStr( 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 + " " return termstr.TermStr(header).bg_color(termstr.Color.grey_50)