From 057edca38ab770d59bba144420b3edc6c2722dbb Mon Sep 17 00:00:00 2001 From: Dominik Jain Date: Tue, 1 Apr 2025 22:44:53 +0200 Subject: [PATCH] Improve log viewer scrolling behaviour [first change by Serena] --- src/serena/gui_log_viewer.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/serena/gui_log_viewer.py b/src/serena/gui_log_viewer.py index 0d38fedd..89a8faa0 100644 --- a/src/serena/gui_log_viewer.py +++ b/src/serena/gui_log_viewer.py @@ -117,6 +117,12 @@ class GuiLogViewer: self.root.quit() return + # Check if scrollbar is at the bottom before adding new text + # Get current scroll position + current_position = self.text_widget.yview() + # If near the bottom (allowing for small floating point differences) + was_at_bottom = current_position[1] > 0.99 + log_level = self._determine_log_level(message) # Insert the message at the end of the text @@ -124,8 +130,9 @@ class GuiLogViewer: self.text_widget.insert(tk.END, message + "\n", log_level.name) self.text_widget.configure(state=tk.DISABLED) - # Auto-scroll to the bottom - self.text_widget.see(tk.END) + # Auto-scroll to the bottom only if it was already at the bottom + if was_at_bottom: + self.text_widget.see(tk.END) # Schedule to check the queue again if self.running: