mirror of https://github.com/Hilbis/Hilbish
fix: hilbish.read overriding history
parent
764e2372a2
commit
4ef6c7d5c0
2
api.go
2
api.go
|
@ -206,7 +206,7 @@ func getenv(key, fallback string) string {
|
||||||
// --- @param prompt string
|
// --- @param prompt string
|
||||||
func hlread(L *lua.LState) int {
|
func hlread(L *lua.LState) int {
|
||||||
luaprompt := L.CheckString(1)
|
luaprompt := L.CheckString(1)
|
||||||
lualr := newLineReader("")
|
lualr := newLineReader("", true)
|
||||||
lualr.SetPrompt(luaprompt)
|
lualr.SetPrompt(luaprompt)
|
||||||
|
|
||||||
input, err := lualr.Read()
|
input, err := lualr.Read()
|
||||||
|
|
2
main.go
2
main.go
|
@ -114,7 +114,7 @@ func main() {
|
||||||
|
|
||||||
go handleSignals()
|
go handleSignals()
|
||||||
luaInit()
|
luaInit()
|
||||||
lr = newLineReader("")
|
lr = newLineReader("", false)
|
||||||
// If user's config doesn't exixt,
|
// If user's config doesn't exixt,
|
||||||
if _, err := os.Stat(defaultConfPath); os.IsNotExist(err) && *configflag == defaultConfPath {
|
if _, err := os.Stat(defaultConfPath); os.IsNotExist(err) && *configflag == defaultConfPath {
|
||||||
// Read default from current directory
|
// Read default from current directory
|
||||||
|
|
6
rl.go
6
rl.go
|
@ -15,8 +15,11 @@ type lineReader struct {
|
||||||
var fileHist *fileHistory
|
var fileHist *fileHistory
|
||||||
|
|
||||||
// other gophers might hate this naming but this is local, shut up
|
// other gophers might hate this naming but this is local, shut up
|
||||||
func newLineReader(prompt string) *lineReader {
|
func newLineReader(prompt string, noHist bool) *lineReader {
|
||||||
rl := readline.NewInstance()
|
rl := readline.NewInstance()
|
||||||
|
// we don't mind hilbish.read rl instances having completion,
|
||||||
|
// but it cant have shared history
|
||||||
|
if !noHist {
|
||||||
fh, err := newFileHistory()
|
fh, err := newFileHistory()
|
||||||
fileHist = fh // go stupid
|
fileHist = fh // go stupid
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -24,6 +27,7 @@ func newLineReader(prompt string) *lineReader {
|
||||||
}
|
}
|
||||||
rl.SetHistoryCtrlR("file", fileHist)
|
rl.SetHistoryCtrlR("file", fileHist)
|
||||||
rl.HistoryAutoWrite = false
|
rl.HistoryAutoWrite = false
|
||||||
|
}
|
||||||
rl.ShowVimMode = false
|
rl.ShowVimMode = false
|
||||||
rl.ViModeCallback = func(mode readline.ViMode) {
|
rl.ViModeCallback = func(mode readline.ViMode) {
|
||||||
modeStr := ""
|
modeStr := ""
|
||||||
|
|
Loading…
Reference in New Issue