Mercurial > vim
comparison src/vim9execute.c @ 24122:e8b21a3bb0d5 v8.2.2602
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Commit: https://github.com/vim/vim/commit/2e34c34be1393027a761ecbccd8f267d52ca7bc1
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Mar 14 12:13:33 2021 +0100
patch 8.2.2602: Vim9: continue doesn't work if :while is very first command
Problem: Vim9: continue doesn't work if :while is very first command.
(Yegappan Lakshmanan)
Solution: Add one to the continue instruction index.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 14 Mar 2021 12:15:03 +0100 |
parents | 0346a59ed5bf |
children | fcbb1d4df15b |
comparison
equal
deleted
inserted
replaced
24121:14d6de7b07b3 | 24122:e8b21a3bb0d5 |
---|---|
28 int tcd_stack_len; // size of ectx.ec_stack at ISN_TRY | 28 int tcd_stack_len; // size of ectx.ec_stack at ISN_TRY |
29 int tcd_catch_idx; // instruction of the first :catch or :finally | 29 int tcd_catch_idx; // instruction of the first :catch or :finally |
30 int tcd_finally_idx; // instruction of the :finally block or zero | 30 int tcd_finally_idx; // instruction of the :finally block or zero |
31 int tcd_endtry_idx; // instruction of the :endtry | 31 int tcd_endtry_idx; // instruction of the :endtry |
32 int tcd_caught; // catch block entered | 32 int tcd_caught; // catch block entered |
33 int tcd_cont; // :continue encountered, jump here | 33 int tcd_cont; // :continue encountered, jump here (minus one) |
34 int tcd_return; // when TRUE return from end of :finally | 34 int tcd_return; // when TRUE return from end of :finally |
35 } trycmd_T; | 35 } trycmd_T; |
36 | 36 |
37 | 37 |
38 // A stack is used to store: | 38 // A stack is used to store: |
2755 // :endtry inside the loop to the loop start. | 2755 // :endtry inside the loop to the loop start. |
2756 for (i = trycont->tct_levels; i > 0; --i) | 2756 for (i = trycont->tct_levels; i > 0; --i) |
2757 { | 2757 { |
2758 trycmd = ((trycmd_T *)trystack->ga_data) | 2758 trycmd = ((trycmd_T *)trystack->ga_data) |
2759 + trystack->ga_len - i; | 2759 + trystack->ga_len - i; |
2760 trycmd->tcd_cont = iidx; | 2760 // Add one to tcd_cont to be able to jump to |
2761 // instruction with index zero. | |
2762 trycmd->tcd_cont = iidx + 1; | |
2761 iidx = trycmd->tcd_finally_idx == 0 | 2763 iidx = trycmd->tcd_finally_idx == 0 |
2762 ? trycmd->tcd_endtry_idx : trycmd->tcd_finally_idx; | 2764 ? trycmd->tcd_endtry_idx : trycmd->tcd_finally_idx; |
2763 } | 2765 } |
2764 // jump to :finally or :endtry of current try statement | 2766 // jump to :finally or :endtry of current try statement |
2765 ectx.ec_iidx = iidx; | 2767 ectx.ec_iidx = iidx; |
2809 clear_tv(STACK_TV_BOT(0)); | 2811 clear_tv(STACK_TV_BOT(0)); |
2810 } | 2812 } |
2811 if (trycmd->tcd_cont != 0) | 2813 if (trycmd->tcd_cont != 0) |
2812 // handling :continue: jump to outer try block or | 2814 // handling :continue: jump to outer try block or |
2813 // start of the loop | 2815 // start of the loop |
2814 ectx.ec_iidx = trycmd->tcd_cont; | 2816 ectx.ec_iidx = trycmd->tcd_cont - 1; |
2815 } | 2817 } |
2816 } | 2818 } |
2817 break; | 2819 break; |
2818 | 2820 |
2819 case ISN_THROW: | 2821 case ISN_THROW: |