Mercurial > vim
comparison src/term.c @ 19489:31ac050a29a7 v8.2.0302
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Commit: https://github.com/vim/vim/commit/0c81d1b11278b2d962aa6fbb4aa974dab97be59d
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Feb 22 22:45:55 2020 +0100
patch 8.2.0302: setting 'term' may cause error in TermChanged autocommand
Problem: Setting 'term' may cause error in TermChanged autocommand.
Solution: Use aucmd_prepbuf() to switch to the buffer where the autocommand
is to be executed. (closes #5682)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 22 Feb 2020 23:00:05 +0100 |
parents | 08f4dc2ba716 |
children | 22f0dda71638 |
comparison
equal
deleted
inserted
replaced
19488:3e8ff1d2fe6c | 19489:31ac050a29a7 |
---|---|
2069 if (scroll_region) | 2069 if (scroll_region) |
2070 scroll_region_reset(); // In case Rows changed | 2070 scroll_region_reset(); // In case Rows changed |
2071 check_map_keycodes(); // check mappings for terminal codes used | 2071 check_map_keycodes(); // check mappings for terminal codes used |
2072 | 2072 |
2073 { | 2073 { |
2074 bufref_T old_curbuf; | 2074 buf_T *buf; |
2075 aco_save_T aco; | |
2075 | 2076 |
2076 /* | 2077 /* |
2077 * Execute the TermChanged autocommands for each buffer that is | 2078 * Execute the TermChanged autocommands for each buffer that is |
2078 * loaded. | 2079 * loaded. |
2079 */ | 2080 */ |
2080 set_bufref(&old_curbuf, curbuf); | 2081 FOR_ALL_BUFFERS(buf) |
2081 FOR_ALL_BUFFERS(curbuf) | |
2082 { | 2082 { |
2083 if (curbuf->b_ml.ml_mfp != NULL) | 2083 if (curbuf->b_ml.ml_mfp != NULL) |
2084 { | |
2085 aucmd_prepbuf(&aco, buf); | |
2084 apply_autocmds(EVENT_TERMCHANGED, NULL, NULL, FALSE, | 2086 apply_autocmds(EVENT_TERMCHANGED, NULL, NULL, FALSE, |
2085 curbuf); | 2087 curbuf); |
2088 // restore curwin/curbuf and a few other things | |
2089 aucmd_restbuf(&aco); | |
2090 } | |
2086 } | 2091 } |
2087 if (bufref_valid(&old_curbuf)) | |
2088 curbuf = old_curbuf.br_buf; | |
2089 } | 2092 } |
2090 } | 2093 } |
2091 | 2094 |
2092 #ifdef FEAT_TERMRESPONSE | 2095 #ifdef FEAT_TERMRESPONSE |
2093 may_req_termresponse(); | 2096 may_req_termresponse(); |