comparison src/syntax.c @ 28357:86b6432aa1d8 v8.2.4704

patch 8.2.4704: using "else" after return or break increases indent Commit: https://github.com/vim/vim/commit/f26c16144ddb27642c09f2cf5271afd163b36306 Author: =?UTF-8?q?Dundar=20G=C3=B6c?= <gocdundar@gmail.com> Date: Thu Apr 7 13:26:34 2022 +0100 patch 8.2.4704: using "else" after return or break increases indent Problem: Using "else" after return or break increases indent. Solution: Remove "else" and reduce indent. (Goc Dundar, closes https://github.com/vim/vim/issues/10099)
author Bram Moolenaar <Bram@vim.org>
date Thu, 07 Apr 2022 14:30:02 +0200
parents 49631bf057d3
children a7556b47ff09
comparison
equal deleted inserted replaced
28356:7225ec1e64cc 28357:86b6432aa1d8
2502 // what matches next may be different now, clear it 2502 // what matches next may be different now, clear it
2503 next_match_idx = 0; 2503 next_match_idx = 0;
2504 next_match_col = MAXCOL; 2504 next_match_col = MAXCOL;
2505 break; 2505 break;
2506 } 2506 }
2507 else 2507
2508 { 2508 // handle next_list, unless at end of line and no "skipnl" or
2509 // handle next_list, unless at end of line and no "skipnl" or 2509 // "skipempty"
2510 // "skipempty" 2510 current_next_list = cur_si->si_next_list;
2511 current_next_list = cur_si->si_next_list; 2511 current_next_flags = cur_si->si_flags;
2512 current_next_flags = cur_si->si_flags; 2512 if (!(current_next_flags & (HL_SKIPNL | HL_SKIPEMPTY))
2513 if (!(current_next_flags & (HL_SKIPNL | HL_SKIPEMPTY)) 2513 && syn_getcurline()[current_col] == NUL)
2514 && syn_getcurline()[current_col] == NUL) 2514 current_next_list = NULL;
2515 current_next_list = NULL; 2515
2516 2516 // When the ended item has "extend", another item with
2517 // When the ended item has "extend", another item with 2517 // "keepend" now needs to check for its end.
2518 // "keepend" now needs to check for its end. 2518 had_extend = (cur_si->si_flags & HL_EXTEND);
2519 had_extend = (cur_si->si_flags & HL_EXTEND); 2519
2520 2520 pop_current_state();
2521 pop_current_state(); 2521
2522 2522 if (current_state.ga_len == 0)
2523 break;
2524
2525 if (had_extend && keepend_level >= 0)
2526 {
2527 syn_update_ends(FALSE);
2523 if (current_state.ga_len == 0) 2528 if (current_state.ga_len == 0)
2524 break; 2529 break;
2525 2530 }
2526 if (had_extend && keepend_level >= 0) 2531
2527 { 2532 cur_si = &CUR_STATE(current_state.ga_len - 1);
2528 syn_update_ends(FALSE); 2533
2529 if (current_state.ga_len == 0) 2534 /*
2530 break; 2535 * Only for a region the search for the end continues after
2531 } 2536 * the end of the contained item. If the contained match
2532 2537 * included the end-of-line, break here, the region continues.
2533 cur_si = &CUR_STATE(current_state.ga_len - 1); 2538 * Don't do this when:
2534 2539 * - "keepend" is used for the contained item
2535 /* 2540 * - not at the end of the line (could be end="x$"me=e-1).
2536 * Only for a region the search for the end continues after 2541 * - "excludenl" is used (HL_HAS_EOL won't be set)
2537 * the end of the contained item. If the contained match 2542 */
2538 * included the end-of-line, break here, the region continues. 2543 if (cur_si->si_idx >= 0
2539 * Don't do this when: 2544 && SYN_ITEMS(syn_block)[cur_si->si_idx].sp_type
2540 * - "keepend" is used for the contained item 2545 == SPTYPE_START
2541 * - not at the end of the line (could be end="x$"me=e-1). 2546 && !(cur_si->si_flags & (HL_MATCH | HL_KEEPEND)))
2542 * - "excludenl" is used (HL_HAS_EOL won't be set) 2547 {
2543 */ 2548 update_si_end(cur_si, (int)current_col, TRUE);
2544 if (cur_si->si_idx >= 0 2549 check_keepend();
2545 && SYN_ITEMS(syn_block)[cur_si->si_idx].sp_type 2550 if ((current_next_flags & HL_HAS_EOL)
2546 == SPTYPE_START 2551 && keepend_level < 0
2547 && !(cur_si->si_flags & (HL_MATCH | HL_KEEPEND))) 2552 && syn_getcurline()[current_col] == NUL)
2548 { 2553 break;
2549 update_si_end(cur_si, (int)current_col, TRUE);
2550 check_keepend();
2551 if ((current_next_flags & HL_HAS_EOL)
2552 && keepend_level < 0
2553 && syn_getcurline()[current_col] == NUL)
2554 break;
2555 }
2556 } 2554 }
2557 } 2555 }
2558 else 2556 else
2559 break; 2557 break;
2560 } 2558 }