Mercurial > vim
comparison src/insexpand.c @ 23770:385d33dfb7df v8.2.2426
patch 8.2.2426: allowing 'completefunc' to switch windows causes trouble
Commit: https://github.com/vim/vim/commit/28976e2accf11591c60e8a658a9e03544f0408b2
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jan 29 21:07:07 2021 +0100
patch 8.2.2426: allowing 'completefunc' to switch windows causes trouble
Problem: Allowing 'completefunc' to switch windows causes trouble.
Solution: use "textwinlock" instead of "textlock".
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 29 Jan 2021 21:15:04 +0100 |
parents | 1371e21fdc3d |
children | f5225486d3de |
comparison
equal
deleted
inserted
replaced
23769:3dd5ed701137 | 23770:385d33dfb7df |
---|---|
2216 args[2].v_type = VAR_UNKNOWN; | 2216 args[2].v_type = VAR_UNKNOWN; |
2217 | 2217 |
2218 pos = curwin->w_cursor; | 2218 pos = curwin->w_cursor; |
2219 curwin_save = curwin; | 2219 curwin_save = curwin; |
2220 curbuf_save = curbuf; | 2220 curbuf_save = curbuf; |
2221 // Lock the text to avoid weird things from happening. Do allow switching | 2221 // Lock the text to avoid weird things from happening. Also disallow |
2222 // to another window temporarily. | 2222 // switching to another window, it should not be needed and may end up in |
2223 ++textlock; | 2223 // Insert mode in another buffer. |
2224 ++textwinlock; | |
2224 | 2225 |
2225 // Call a function, which returns a list or dict. | 2226 // Call a function, which returns a list or dict. |
2226 if (call_vim_function(funcname, 2, args, &rettv) == OK) | 2227 if (call_vim_function(funcname, 2, args, &rettv) == OK) |
2227 { | 2228 { |
2228 switch (rettv.v_type) | 2229 switch (rettv.v_type) |
2241 // TODO: Give error message? | 2242 // TODO: Give error message? |
2242 clear_tv(&rettv); | 2243 clear_tv(&rettv); |
2243 break; | 2244 break; |
2244 } | 2245 } |
2245 } | 2246 } |
2246 --textlock; | 2247 --textwinlock; |
2247 | 2248 |
2248 if (curwin_save != curwin || curbuf_save != curbuf) | 2249 if (curwin_save != curwin || curbuf_save != curbuf) |
2249 { | 2250 { |
2250 emsg(_(e_complwin)); | 2251 emsg(_(e_complwin)); |
2251 goto theend; | 2252 goto theend; |
3224 // time of 'always', compl_shown_match become NULL. | 3225 // time of 'always', compl_shown_match become NULL. |
3225 if (compl_shown_match == NULL) | 3226 if (compl_shown_match == NULL) |
3226 return -1; | 3227 return -1; |
3227 | 3228 |
3228 if (compl_leader != NULL | 3229 if (compl_leader != NULL |
3229 && (compl_shown_match->cp_flags & CP_ORIGINAL_TEXT) == 0) | 3230 && (compl_shown_match->cp_flags & CP_ORIGINAL_TEXT) == 0) |
3230 { | 3231 { |
3231 // Set "compl_shown_match" to the actually shown match, it may differ | 3232 // Set "compl_shown_match" to the actually shown match, it may differ |
3232 // when "compl_leader" is used to omit some of the matches. | 3233 // when "compl_leader" is used to omit some of the matches. |
3233 while (!ins_compl_equal(compl_shown_match, | 3234 while (!ins_compl_equal(compl_shown_match, |
3234 compl_leader, (int)STRLEN(compl_leader)) | 3235 compl_leader, (int)STRLEN(compl_leader)) |