fixing docs

This commit is contained in:
dullfig 2026-01-11 16:01:04 -08:00
parent fff43f1a78
commit a9035d34d8

View file

@ -112,7 +112,7 @@ class OutputBuffer:
# Check if cursor is at end (user hasn't scrolled up) # Check if cursor is at end (user hasn't scrolled up)
old_text = self.buffer.text old_text = self.buffer.text
was_at_end = self.is_at_bottom() # Use new method was_at_end = self.buffer.cursor_position >= len(old_text)
# Update buffer text # Update buffer text
text = "\n".join(self._lines) text = "\n".join(self._lines)
@ -120,10 +120,9 @@ class OutputBuffer:
if was_at_end: if was_at_end:
# Stay at bottom - auto-scroll # Stay at bottom - auto-scroll
self.buffer.set_document( self.buffer.set_document(
Document(text=text), # Removed cursor_position Document(text=text, cursor_position=len(text)),
bypass_readonly=True bypass_readonly=True
) )
self.buffer.cursor_position = len(text) # Force bottom
else: else:
# Preserve scroll position - silent append # Preserve scroll position - silent append
old_pos = self.buffer.cursor_position old_pos = self.buffer.cursor_position
@ -132,13 +131,15 @@ class OutputBuffer:
bypass_readonly=True bypass_readonly=True
) )
def scroll_to_bottom(self):
"""Snap to bottom."""
self.buffer.cursor_position = len(self.buffer.text)
def is_at_bottom(self) -> bool: def is_at_bottom(self) -> bool:
"""Cursor at/near end? (tolerance 1 line).""" """Check if output is scrolled to bottom (or near bottom)."""
return self.buffer.cursor_position >= len(self.buffer.text) - len(self.buffer.text.split('\n', 1)[0]) - 1 doc = self.buffer.document
# Consider "at bottom" if on last 3 lines
return doc.cursor_position_row >= doc.line_count - 3
def scroll_to_bottom(self):
"""Scroll to the very bottom."""
self.buffer.cursor_position = len(self.buffer.text)
def clear(self): def clear(self):
"""Clear output.""" """Clear output."""