Mercurial > vim
comparison src/screen.c @ 31018:9716c7d24c12 v9.0.0844
patch 9.0.0844: handling 'statusline' errors is spread out
Commit: https://github.com/vim/vim/commit/7b224fdf4a29f115567d4fc8629c1cef92d8444a
Author: Luuk van Baal <luukvbaal@gmail.com>
Date: Mon Nov 7 12:16:51 2022 +0000
patch 9.0.0844: handling 'statusline' errors is spread out
Problem: Handling 'statusline' errors is spread out.
Solution: Pass the option name to the lower levels so the option can be
reset there when an error is encountered. (Luuk van Baal,
closes #11467)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 07 Nov 2022 13:30:04 +0100 |
parents | 360f286b5869 |
children | 50405a481037 |
comparison
equal
deleted
inserted
replaced
31017:99a1b64051b5 | 31018:9716c7d24c12 |
---|---|
1282 int len; | 1282 int len; |
1283 int fillchar; | 1283 int fillchar; |
1284 char_u buf[MAXPATHL]; | 1284 char_u buf[MAXPATHL]; |
1285 char_u *stl; | 1285 char_u *stl; |
1286 char_u *p; | 1286 char_u *p; |
1287 char_u *opt_name; | |
1288 int opt_scope = 0; | |
1287 stl_hlrec_T *hltab; | 1289 stl_hlrec_T *hltab; |
1288 stl_hlrec_T *tabtab; | 1290 stl_hlrec_T *tabtab; |
1289 int use_sandbox = FALSE; | |
1290 win_T *ewp; | 1291 win_T *ewp; |
1291 int p_crb_save; | 1292 int p_crb_save; |
1292 | 1293 |
1293 // There is a tiny chance that this gets called recursively: When | 1294 // There is a tiny chance that this gets called recursively: When |
1294 // redrawing a status line triggers redrawing the ruler or tabline. | 1295 // redrawing a status line triggers redrawing the ruler or tabline. |
1304 stl = p_tal; | 1305 stl = p_tal; |
1305 row = 0; | 1306 row = 0; |
1306 fillchar = ' '; | 1307 fillchar = ' '; |
1307 attr = HL_ATTR(HLF_TPF); | 1308 attr = HL_ATTR(HLF_TPF); |
1308 maxwidth = Columns; | 1309 maxwidth = Columns; |
1309 # ifdef FEAT_EVAL | 1310 opt_name = (char_u *)"tabline"; |
1310 use_sandbox = was_set_insecurely((char_u *)"tabline", 0); | |
1311 # endif | |
1312 } | 1311 } |
1313 else | 1312 else |
1314 { | 1313 { |
1315 row = statusline_row(wp); | 1314 row = statusline_row(wp); |
1316 fillchar = fillchar_status(&attr, wp); | 1315 fillchar = fillchar_status(&attr, wp); |
1317 maxwidth = wp->w_width; | 1316 maxwidth = wp->w_width; |
1318 | 1317 |
1319 if (draw_ruler) | 1318 if (draw_ruler) |
1320 { | 1319 { |
1321 stl = p_ruf; | 1320 stl = p_ruf; |
1321 opt_name = (char_u *)"rulerformat"; | |
1322 // advance past any leading group spec - implicit in ru_col | 1322 // advance past any leading group spec - implicit in ru_col |
1323 if (*stl == '%') | 1323 if (*stl == '%') |
1324 { | 1324 { |
1325 if (*++stl == '-') | 1325 if (*++stl == '-') |
1326 stl++; | 1326 stl++; |
1339 row = Rows - 1; | 1339 row = Rows - 1; |
1340 --maxwidth; // writing in last column may cause scrolling | 1340 --maxwidth; // writing in last column may cause scrolling |
1341 fillchar = ' '; | 1341 fillchar = ' '; |
1342 attr = 0; | 1342 attr = 0; |
1343 } | 1343 } |
1344 | |
1345 # ifdef FEAT_EVAL | |
1346 use_sandbox = was_set_insecurely((char_u *)"rulerformat", 0); | |
1347 # endif | |
1348 } | 1344 } |
1349 else | 1345 else |
1350 { | 1346 { |
1347 opt_name = (char_u *)"statusline"; | |
1351 if (*wp->w_p_stl != NUL) | 1348 if (*wp->w_p_stl != NUL) |
1349 { | |
1352 stl = wp->w_p_stl; | 1350 stl = wp->w_p_stl; |
1351 opt_scope = OPT_LOCAL; | |
1352 } | |
1353 else | 1353 else |
1354 stl = p_stl; | 1354 stl = p_stl; |
1355 # ifdef FEAT_EVAL | |
1356 use_sandbox = was_set_insecurely((char_u *)"statusline", | |
1357 *wp->w_p_stl == NUL ? 0 : OPT_LOCAL); | |
1358 # endif | |
1359 } | 1355 } |
1360 | 1356 |
1361 col += wp->w_wincol; | 1357 col += wp->w_wincol; |
1362 } | 1358 } |
1363 | 1359 |
1372 | 1368 |
1373 // Make a copy, because the statusline may include a function call that | 1369 // Make a copy, because the statusline may include a function call that |
1374 // might change the option value and free the memory. | 1370 // might change the option value and free the memory. |
1375 stl = vim_strsave(stl); | 1371 stl = vim_strsave(stl); |
1376 width = build_stl_str_hl(ewp, buf, sizeof(buf), | 1372 width = build_stl_str_hl(ewp, buf, sizeof(buf), |
1377 stl, use_sandbox, | 1373 stl, opt_name, opt_scope, |
1378 fillchar, maxwidth, &hltab, &tabtab); | 1374 fillchar, maxwidth, &hltab, &tabtab); |
1379 vim_free(stl); | 1375 vim_free(stl); |
1380 ewp->w_p_crb = p_crb_save; | 1376 ewp->w_p_crb = p_crb_save; |
1381 | 1377 |
1382 // Make all characters printable. | 1378 // Make all characters printable. |
4545 #if defined(FEAT_STL_OPT) | 4541 #if defined(FEAT_STL_OPT) |
4546 clear_TabPageIdxs(); | 4542 clear_TabPageIdxs(); |
4547 | 4543 |
4548 // Use the 'tabline' option if it's set. | 4544 // Use the 'tabline' option if it's set. |
4549 if (*p_tal != NUL) | 4545 if (*p_tal != NUL) |
4550 { | |
4551 int saved_did_emsg = did_emsg; | |
4552 | |
4553 // Check for an error. If there is one we would loop in redrawing the | |
4554 // screen. Avoid that by making 'tabline' empty. | |
4555 did_emsg = FALSE; | |
4556 win_redr_custom(NULL, FALSE); | 4546 win_redr_custom(NULL, FALSE); |
4557 if (did_emsg) | |
4558 set_string_option_direct((char_u *)"tabline", -1, | |
4559 (char_u *)"", OPT_FREE, SID_ERROR); | |
4560 did_emsg |= saved_did_emsg; | |
4561 } | |
4562 else | 4547 else |
4563 #endif | 4548 #endif |
4564 { | 4549 { |
4565 FOR_ALL_TABPAGES(tp) | 4550 FOR_ALL_TABPAGES(tp) |
4566 ++tabcount; | 4551 ++tabcount; |