fix history indexing down

This commit is contained in:
2025-02-22 01:39:21 -05:00
parent 1fe21b1592
commit bf40d524b7
3 changed files with 9 additions and 8 deletions

View File

@ -1,4 +1,4 @@
import history_cmd from "./builtin/history"
import history from "./builtin/history"
import clear from "./builtin/clear"
import pwd from "./builtin/pwd"
import cat from "./builtin/cat"
@ -8,12 +8,13 @@ import ls from "./builtin/ls"
type Term = HTMLElement
type Args = string[]
type Command = (term: Term, args: Args) => boolean
interface CommandsList {
[index: string]: Command,
}
const commands: CommandsList = {
["history"]: history_cmd,
["history"]: history,
["clear"]: clear,
["pwd"]: pwd,
["cat"]: cat,

View File

@ -36,7 +36,7 @@ history.index_down = function(ps1input: HTMLInputElement) {
if (this.file.cursor!==0) {
this.file.cursor-=1
if (this.file.cursor!==0) {
const item = this.file.inner[this.file.cursor]
const item = this.file.inner[this.file.cursor-1]
if (item) { ps1input.value = item }
} else {
this.file.cursor_reset()