mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-14 19:27:58 +08:00
edit: Call after-readline hooks before tearing down editor.
This fixes #589.
This commit is contained in:
parent
c8cf6a1f61
commit
b77b3d7846
13
edit/edit.go
13
edit/edit.go
|
@ -310,6 +310,12 @@ func (ed *editor) startReadLine() error {
|
|||
// finishReadLine puts the terminal in a state suitable for other programs to
|
||||
// use.
|
||||
func (ed *editor) finishReadLine() error {
|
||||
// After-readline hooks should be called before most teardown happens as
|
||||
// they can cause the editor to refresh.
|
||||
for _, f := range ed.afterReadline {
|
||||
f(ed.buffer)
|
||||
}
|
||||
|
||||
ed.activeMutex.Lock()
|
||||
defer ed.activeMutex.Unlock()
|
||||
ed.active = false
|
||||
|
@ -331,14 +337,9 @@ func (ed *editor) finishReadLine() error {
|
|||
// Restore termios.
|
||||
errRestore := ed.restoreTerminal()
|
||||
|
||||
// Save the line before resetting all of editorState.
|
||||
line := ed.buffer
|
||||
// Reset all of editorState.
|
||||
ed.editorState = editorState{}
|
||||
|
||||
for _, f := range ed.afterReadline {
|
||||
f(line)
|
||||
}
|
||||
|
||||
return util.Errors(errRefresh, errRestore)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user