Reordered prompt done callback to avoid accessing out of bound history (#3318)
* Reordered prompt done callback to avoid accessing out of bound history * Formatting
This commit is contained in:
parent
e9bd1b35f4
commit
dd913df9e9
1 changed files with 3 additions and 2 deletions
|
@ -143,13 +143,12 @@ func (i *InfoBuf) DonePrompt(canceled bool) {
|
|||
if i.PromptCallback != nil {
|
||||
if canceled {
|
||||
i.Replace(i.Start(), i.End(), "")
|
||||
i.PromptCallback("", true)
|
||||
h := i.History[i.PromptType]
|
||||
i.History[i.PromptType] = h[:len(h)-1]
|
||||
i.PromptCallback("", true)
|
||||
} else {
|
||||
resp := string(i.LineBytes(0))
|
||||
i.Replace(i.Start(), i.End(), "")
|
||||
i.PromptCallback(resp, false)
|
||||
h := i.History[i.PromptType]
|
||||
h[len(h)-1] = resp
|
||||
|
||||
|
@ -160,6 +159,8 @@ func (i *InfoBuf) DonePrompt(canceled bool) {
|
|||
break
|
||||
}
|
||||
}
|
||||
|
||||
i.PromptCallback(resp, false)
|
||||
}
|
||||
// i.PromptCallback = nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue