Make TermClose event return the associated buffer

<abuf> from the TermClose event now returns the correct buffer number.

Prior to this change it would always return the buffer number of the current
buffer, which is obviously wrong in an async environment.
This commit is contained in:
Marco Hinz
2016-02-19 17:31:23 +01:00
parent 44024f2c65
commit fe8b2fabe7
2 changed files with 6 additions and 2 deletions

View File

@@ -22199,7 +22199,6 @@ static void on_process_exit(Process *proc, int status, void *d)
char msg[22]; char msg[22];
snprintf(msg, sizeof msg, "\r\n[Process exited %d]", proc->status); snprintf(msg, sizeof msg, "\r\n[Process exited %d]", proc->status);
terminal_close(data->term, msg); terminal_close(data->term, msg);
apply_autocmds(EVENT_TERMCLOSE, NULL, NULL, false, curbuf);
} }
if (data->status_ptr) { if (data->status_ptr) {

View File

@@ -288,8 +288,9 @@ void terminal_close(Terminal *term, char *msg)
term->forward_mouse = false; term->forward_mouse = false;
term->closed = true; term->closed = true;
if (!msg || exiting) {
buf_T *buf = handle_get_buffer(term->buf_handle); buf_T *buf = handle_get_buffer(term->buf_handle);
if (!msg || exiting) {
// If no msg was given, this was called by close_buffer(buffer.c). Or if // If no msg was given, this was called by close_buffer(buffer.c). Or if
// exiting, we must inform the buffer the terminal no longer exists so that // exiting, we must inform the buffer the terminal no longer exists so that
// close_buffer() doesn't call this again. // close_buffer() doesn't call this again.
@@ -304,6 +305,10 @@ void terminal_close(Terminal *term, char *msg)
} else { } else {
terminal_receive(term, msg, strlen(msg)); terminal_receive(term, msg, strlen(msg));
} }
if (buf) {
apply_autocmds(EVENT_TERMCLOSE, NULL, NULL, false, buf);
}
} }
void terminal_resize(Terminal *term, uint16_t width, uint16_t height) void terminal_resize(Terminal *term, uint16_t width, uint16_t height)