mirror of
https://github.com/tiennm99/serena.git
synced 2026-10-13 10:16:00 +00:00
Improve log viewer scrolling behaviour [first change by Serena]
This commit is contained in:
1 parent
accf9e141f
commit
057edca38a
1 file changed
+9
-2
@@ -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:
|
||||
|
||||
Reference in new issue
Block a user