fixed up arrow bug
This commit is contained in:
@@ -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 = clamp(historyIndex, 0, terminalHistory.size() - 1)
|
||||
historyIndex -= direction
|
||||
|
||||
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()
|
||||
|
||||
func CreateHistoryEntry(content: String) -> void:
|
||||
|
||||
Reference in New Issue
Block a user