Skip to content

Commit 03d98c5

Browse files
committed
Fix log separators filtering
1 parent cee5748 commit 03d98c5

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

midiscripter/gui/log_widget.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,18 +101,21 @@ def __set_lines_visibility(self, last_n_blocks: int = 0) -> None:
101101

102102
start_from_block_number = 0 if not last_n_blocks else document.blockCount() - last_n_blocks
103103

104+
previous_visible_entry = None
104105
for line_n in range(start_from_block_number, document.blockCount()):
105106
block = document.findBlockByNumber(line_n)
106107
log_entry = block.text()[self.entry_ctime_part_len :]
107108

108-
if (
109-
log_entry
110-
and self.__text_line_is_excluded(log_entry)
109+
if log_entry and ( # noqa: SIM114
110+
self.__text_line_is_excluded(log_entry)
111111
or not self.__text_line_matches_filter(log_entry)
112112
):
113113
block.setVisible(False)
114+
elif not log_entry and not previous_visible_entry: # two separators in a row
115+
block.setVisible(False)
114116
else:
115117
block.setVisible(True)
118+
previous_visible_entry = log_entry
116119

117120
self.setDocument(document)
118121

@@ -170,7 +173,7 @@ def __add_entry(self, log_entries: list[str]) -> None:
170173
self.verticalScrollBar().setValue(self.verticalScrollBar().maximum())
171174

172175
if self.__filter_text_parts or self.__exclude_text_parts:
173-
self.__apply_filter(len(log_entries))
176+
self.__apply_filter(len(log_entries) + 1)
174177

175178
@staticmethod
176179
def pause_logging() -> None:

0 commit comments

Comments
 (0)