Mercurial > vim
comparison src/scriptfile.c @ 26745:dcd1c244e332 v8.2.3901
patch 8.2.3901: Vim9: Cannot set 'cpo' in main .vimrc if using Vim9 script
Commit: https://github.com/vim/vim/commit/71eb3ad5790ef3d16369e2fceb040980d75539cf
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Dec 26 12:07:30 2021 +0000
patch 8.2.3901: Vim9: Cannot set 'cpo' in main .vimrc if using Vim9 script
Problem: Vim9: Cannot set 'cpo' in main .vimrc if using Vim9 script.
Solution: Do not restore 'cpo' at the end of the main .vimrc.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 26 Dec 2021 13:15:03 +0100 |
parents | 8b8470b511f5 |
children | fc859aea8cec |
comparison
equal
deleted
inserted
replaced
26744:87a61ed592e6 | 26745:dcd1c244e332 |
---|---|
1370 si->sn_name = fname_exp; | 1370 si->sn_name = fname_exp; |
1371 fname_exp = vim_strsave(si->sn_name); // used for autocmd | 1371 fname_exp = vim_strsave(si->sn_name); // used for autocmd |
1372 if (ret_sid != NULL) | 1372 if (ret_sid != NULL) |
1373 *ret_sid = current_sctx.sc_sid; | 1373 *ret_sid = current_sctx.sc_sid; |
1374 | 1374 |
1375 // Remember the "is_vimrc" flag for when the file is sourced again. | |
1376 si->sn_is_vimrc = is_vimrc; | |
1377 | |
1375 // Used to check script variable index is still valid. | 1378 // Used to check script variable index is still valid. |
1376 si->sn_script_seq = current_sctx.sc_seq; | 1379 si->sn_script_seq = current_sctx.sc_seq; |
1377 } | 1380 } |
1378 | 1381 |
1379 # ifdef FEAT_PROFILE | 1382 # ifdef FEAT_PROFILE |
1469 ++debug_break_level; | 1472 ++debug_break_level; |
1470 #endif | 1473 #endif |
1471 | 1474 |
1472 #ifdef FEAT_EVAL | 1475 #ifdef FEAT_EVAL |
1473 almosttheend: | 1476 almosttheend: |
1477 // If "sn_save_cpo" is set that means we encountered "vim9script": restore | |
1478 // 'cpoptions', unless in the main .vimrc file. | |
1474 // Get "si" again, "script_items" may have been reallocated. | 1479 // Get "si" again, "script_items" may have been reallocated. |
1475 si = SCRIPT_ITEM(current_sctx.sc_sid); | 1480 si = SCRIPT_ITEM(current_sctx.sc_sid); |
1476 if (si->sn_save_cpo != NULL) | 1481 if (si->sn_save_cpo != NULL && si->sn_is_vimrc == DOSO_NONE) |
1477 { | 1482 { |
1478 if (STRCMP(p_cpo, CPO_VIM) != 0) | 1483 if (STRCMP(p_cpo, CPO_VIM) != 0) |
1479 { | 1484 { |
1480 char_u *f; | 1485 char_u *f; |
1481 char_u *t; | 1486 char_u *t; |
1501 si->sn_save_cpo = t; | 1506 si->sn_save_cpo = t; |
1502 } | 1507 } |
1503 } | 1508 } |
1504 } | 1509 } |
1505 set_option_value((char_u *)"cpo", 0L, si->sn_save_cpo, OPT_NO_REDRAW); | 1510 set_option_value((char_u *)"cpo", 0L, si->sn_save_cpo, OPT_NO_REDRAW); |
1506 VIM_CLEAR(si->sn_save_cpo); | 1511 } |
1507 } | 1512 VIM_CLEAR(si->sn_save_cpo); |
1508 | 1513 |
1509 restore_funccal(); | 1514 restore_funccal(); |
1510 # ifdef FEAT_PROFILE | 1515 # ifdef FEAT_PROFILE |
1511 if (do_profiling == PROF_YES) | 1516 if (do_profiling == PROF_YES) |
1512 prof_child_exit(&wait_start); // leaving a child now | 1517 prof_child_exit(&wait_start); // leaving a child now |