fixed up arrow bug

This commit is contained in:
Brazly
2026-02-16 20:50:15 +00:00
parent 1c9d43a5f7
commit 3684788237

View File

@@ -8,7 +8,7 @@ class_name TerminalControls
@onready var scroll: ScrollContainer = $MarginContainer/ScrollContainer
@export var terminalLine: RichTextLabel
var terminalHistory: Array[String] = [""]
var terminalHistory: Array[String] = []
var historyIndex: int = -1
var cursorIndexFromEnd: int = 0
@@ -89,7 +89,7 @@ func EnterCommand() -> void:
if userInput != "":
terminalHistory.append(userInput)
historyIndex = 0
historyIndex = terminalHistory.size()
cursorIndexFromEnd = 0
match parts[0]:
@@ -177,12 +177,16 @@ func NavigateHistory(direction: int):
if terminalHistory.is_empty():
return
historyIndex += direction
historyIndex -= direction
if historyIndex >= terminalHistory.size():
historyIndex = terminalHistory.size()
terminalLine.text = "user@work "+ directory + " "
else:
historyIndex = clamp(historyIndex, 0, terminalHistory.size() - 1)
var historyCommand = terminalHistory[historyIndex]
terminalLine.text = "user@work "+ directory + " " + historyCommand
UpdateCaretPos()
func CreateHistoryEntry(content: String) -> void: