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