fix history bug, add jale.nim for version info

This commit is contained in:
Productive2 2021-02-26 14:23:53 +01:00
parent add1dd8c31
commit d4d2f52ec1
3 changed files with 6 additions and 1 deletions

1
src/jale.nim Normal file
View File

@ -0,0 +1 @@
const jaleVersion = "0.1"

View File

@ -10,6 +10,7 @@ proc plugHistory*(ed: LineEditor): History =
# after reading finished, it adds to history
# before reading, it adds the temporary input to the history
let hist = newHistory()
ed.bindEvent(jeFinish):
hist.clean()
hist.newEntry(ed.content)

View File

@ -68,7 +68,10 @@ proc clean*(h: History) =
h.lowestTouchedIndex = h.elements.len()
proc newEntry*(h: History, ml: Multiline, temp: bool = false) =
h.elements.add(HistoryElement(original: ml, current: ml.copy(), temp: temp))
if not temp:
h.elements.add(HistoryElement(original: ml, current: ml.copy(), temp: temp))
else:
h.elements.add(HistoryElement(original: ml, current: ml, temp: temp))
proc save*(h: History, path: string) =
# discards currents and temps, only saves originals