<commit_before>package conio

type HistoryLine struct {
	Line string
	Word []string
}

func NewHistoryLine(line string) *HistoryLine {
	return &HistoryLine{Line: line, Word: SplitQ(line)}
}

func (this *HistoryLine) At(n int) string {
	for n < 0 {
		n += len(this.Word)
	}
	return this.Word[n%len(this.Word)]
}

var Histories = make([]*HistoryLine, 0)
var HistoryPointer = 0

func GetHistory(n int) *HistoryLine {
	if n < 0 {
		n = len(Histories) + n
	}
	if n >= len(Histories) {
		return nil
	} else {
		return Histories[n]
	}
}

func HistoryLen() int {
	return len(Histories)
}

func LastHistory() *HistoryLine {
	if len(Histories) <= 0 {
		return nil
	} else {
		return Histories[len(Histories)-1]
	}
}

func KeyFuncHistoryUp(this *Buffer) Result {
	if HistoryPointer <= 0 {
		HistoryPointer = len(Histories)
	}
	HistoryPointer -= 1
	KeyFuncClear(this)
	if HistoryPointer >= 0 {
		this.InsertString(0, Histories[HistoryPointer].Line)
		this.ViewStart = 0<commit_msg>Fix: crashed for large arg on nyagos.gethistory (#38)<commit_after>package conio

type HistoryLine struct {
	Line string
	Word []string
}

func NewHistoryLine(line string) *HistoryLine {
	return &HistoryLine{Line: line, Word: SplitQ(line)}
}

func (this *HistoryLine) At(n int) string {
	for n < 0 {
		n += len(this.Word)
	}
	return this.Word[n%len(this.Word)]
}

var Histories = make([]*HistoryLine, 0)
var HistoryPointer = 0

func GetHistory(n int) *HistoryLine {
	if n < 0 {
		n = len(Histories) + n
	}
	if n >= len(Histories) {
		return &HistoryLine{Line: "", Word: []string{}}
	} else {
		return Histories[n]
	}
}

func HistoryLen() int {
	return len(Histories)
}

func LastHistory() *HistoryLine {
	if len(Histories) <= 0 {
		return nil
	} else {
		return Histories[len(Histories)-1]
	}
}

func KeyFuncHistoryUp(this *Buffer) Result {
	if HistoryPointer <= 0 {
		HistoryPointer = len(Histories)
	}
	HistoryPointer -= 1
	KeyFuncClear(this)
	if HistoryPointer >= 0 {
		this.InsertString(0, Histories[HistoryPointer].Line)
		this.ViewStart = 0
{'fraction_non_alphanumeric': 0.13052109181141439, 'fraction_numerical': 0.011910669975186104, 'mean_word_length': 4.25, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2204068', 'n_tokens_mistral': 770, 'n_tokens_neox': 729, 'n_words': 190}