fix: refine dynamic height adjustment for input area in CLI

- Updated the input area height calculation to ensure it matches the exact line count of content, eliminating extra blank space.
- Adjusted the return values to improve the responsiveness of the input area, enhancing user experience when adding newlines.
This commit is contained in:
teknium1 2026-02-19 01:53:36 -08:00
parent 0e8ee051c6
commit 109dffb242

12
cli.py
View file

@ -1651,16 +1651,16 @@ class HermesCLI:
complete_while_typing=True, complete_while_typing=True,
) )
# Dynamic height: grow the input area to match content lines so # Dynamic height: return the exact line count so the TextArea is
# newlines (Alt+Enter) are always visible. A static preferred=1 # always exactly as tall as its content -- no extra blank space.
# causes the widget to stay 1-line and scroll internally after # The bottom rule sits directly below the last line of text and
# patch_stdout output has filled the terminal. # pushes down only when the user adds a newline.
def _input_height(): def _input_height():
try: try:
lines = input_area.buffer.document.line_count lines = input_area.buffer.document.line_count
return Dimension(min=1, max=8, preferred=max(lines, 1)) return min(max(lines, 1), 8)
except Exception: except Exception:
return Dimension(min=1, max=8, preferred=1) return 1
input_area.window.height = _input_height input_area.window.height = _input_height