fixed text overflowing at the bottom by always setting the scroll value to be the max

This commit is contained in:
Brazly
2026-01-18 13:01:28 +00:00
parent 0247e53de7
commit e1a302ff24
3 changed files with 12 additions and 11 deletions

View File

@@ -59,7 +59,7 @@ func EnterCommand() -> void:
var userInput = fullText.trim_prefix("user@work " + directory).strip_edges()
var parts = userInput.to_lower().split(" ")
if historyContainer.get_child_count() <22:
if historyContainer.get_child_count() <24:
CreateHistoryEntry(fullText)
match parts[0]:
@@ -107,6 +107,7 @@ func EnterCommand() -> void:
terminalLine.text = "user@work "+ directory + " "
UpdateCaretPos()
GetBottomScroll()
# --- History and FileSystem Helpers ---
func CreateHistoryEntry(content: String) -> void:
@@ -124,10 +125,6 @@ func CreateHistoryEntry(content: String) -> void:
historyContainer.add_child(label)
historyContainer.move_child(label, historyContainer.get_child_count() - 2)
# Limit history to 15 entries + 1 active line
if historyContainer.get_child_count() > 17:
historyContainer.get_child(0).queue_free()
func ResolvePath(current: String, target: String) -> String:
if target.begins_with("~/"):
return target if target.ends_with("/") else target + "/"
@@ -188,9 +185,6 @@ func RetrieveData(inputPath: String):
CreateHistoryEntry("cat: " + targetFileName + ": No such file or directory")
func Help(commandName: String = "default"):
for child in historyContainer.get_children():
if child != terminalLine:
child.queue_free()
match commandName:
"default": CreateHistoryEntry("--- AVAILABLE COMMANDS ---
ls (or list) [folder] : List all files and directories/folders
@@ -202,7 +196,13 @@ help : Show this menu
func GetBottomScroll():
var scroll: ScrollContainer = $MarginContainer/ScrollContainer
var scrollMax: float = scroll.get_v_scroll_bar().max_value
await get_tree().create_timer(.01).timeout
scroll.set_deferred("scroll_vertical", scrollMax)
call_deferred("GetBottomScroll")
func UpdateCaretPos():
var last_char_index = terminalLine.text.length() - 1