Mercurial > vim
comparison src/indent.c @ 28716:2bd5cb054180 v8.2.4882
patch 8.2.4882: cannot make 'breakindent' use a specific column
Commit: https://github.com/vim/vim/commit/e7d6dbc5721342e3d6b04cf285e4510b5569e707
Author: Christian Brabandt <cb@256bit.org>
Date: Fri May 6 12:21:04 2022 +0100
patch 8.2.4882: cannot make 'breakindent' use a specific column
Problem: Cannot make 'breakindent' use a specific column.
Solution: Add the "column" entry in 'breakindentopt'. (Christian Brabandt,
closes #10362, closes #10325)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 06 May 2022 13:30:03 +0200 |
parents | 63e9b0016a6c |
children | d770568e6c98 |
comparison
equal
deleted
inserted
replaced
28715:ee1368645d58 | 28716:2bd5cb054180 |
---|---|
864 char_u *p; | 864 char_u *p; |
865 int bri_shift = 0; | 865 int bri_shift = 0; |
866 long bri_min = 20; | 866 long bri_min = 20; |
867 int bri_sbr = FALSE; | 867 int bri_sbr = FALSE; |
868 int bri_list = 0; | 868 int bri_list = 0; |
869 int bri_vcol = 0; | |
869 | 870 |
870 p = wp->w_p_briopt; | 871 p = wp->w_p_briopt; |
871 while (*p != NUL) | 872 while (*p != NUL) |
872 { | 873 { |
873 if (STRNCMP(p, "shift:", 6) == 0 | 874 if (STRNCMP(p, "shift:", 6) == 0 |
888 } | 889 } |
889 else if (STRNCMP(p, "list:", 5) == 0) | 890 else if (STRNCMP(p, "list:", 5) == 0) |
890 { | 891 { |
891 p += 5; | 892 p += 5; |
892 bri_list = getdigits(&p); | 893 bri_list = getdigits(&p); |
894 } | |
895 else if (STRNCMP(p, "column:", 7) == 0) | |
896 { | |
897 p += 7; | |
898 bri_vcol = getdigits(&p); | |
893 } | 899 } |
894 if (*p != ',' && *p != NUL) | 900 if (*p != ',' && *p != NUL) |
895 return FAIL; | 901 return FAIL; |
896 if (*p == ',') | 902 if (*p == ',') |
897 ++p; | 903 ++p; |
899 | 905 |
900 wp->w_briopt_shift = bri_shift; | 906 wp->w_briopt_shift = bri_shift; |
901 wp->w_briopt_min = bri_min; | 907 wp->w_briopt_min = bri_min; |
902 wp->w_briopt_sbr = bri_sbr; | 908 wp->w_briopt_sbr = bri_sbr; |
903 wp->w_briopt_list = bri_list; | 909 wp->w_briopt_list = bri_list; |
910 wp->w_briopt_vcol = bri_vcol; | |
904 | 911 |
905 return OK; | 912 return OK; |
906 } | 913 } |
907 | 914 |
908 /* | 915 /* |
951 prev_line = line; | 958 prev_line = line; |
952 prev_ts = wp->w_buffer->b_p_ts; | 959 prev_ts = wp->w_buffer->b_p_ts; |
953 prev_tick = CHANGEDTICK(wp->w_buffer); | 960 prev_tick = CHANGEDTICK(wp->w_buffer); |
954 # ifdef FEAT_VARTABS | 961 # ifdef FEAT_VARTABS |
955 prev_vts = wp->w_buffer->b_p_vts_array; | 962 prev_vts = wp->w_buffer->b_p_vts_array; |
956 prev_indent = get_indent_str_vtab(line, | 963 if (wp->w_briopt_vcol == 0) |
964 prev_indent = get_indent_str_vtab(line, | |
957 (int)wp->w_buffer->b_p_ts, | 965 (int)wp->w_buffer->b_p_ts, |
958 wp->w_buffer->b_p_vts_array, wp->w_p_list); | 966 wp->w_buffer->b_p_vts_array, wp->w_p_list); |
959 # else | 967 # else |
960 prev_indent = get_indent_str(line, | 968 if (wp->w_briopt_vcol == 0) |
969 prev_indent = get_indent_str(line, | |
961 (int)wp->w_buffer->b_p_ts, wp->w_p_list); | 970 (int)wp->w_buffer->b_p_ts, wp->w_p_list); |
962 # endif | 971 # endif |
963 prev_listopt = wp->w_briopt_list; | 972 prev_listopt = wp->w_briopt_list; |
964 prev_list = 0; | 973 prev_list = 0; |
965 vim_free(prev_flp); | 974 vim_free(prev_flp); |
966 prev_flp = vim_strsave(get_flp_value(wp->w_buffer)); | 975 prev_flp = vim_strsave(get_flp_value(wp->w_buffer)); |
967 // add additional indent for numbered lists | 976 // add additional indent for numbered lists |
968 if (wp->w_briopt_list != 0) | 977 if (wp->w_briopt_list != 0 && wp->w_briopt_vcol == 0) |
969 { | 978 { |
970 regmatch_T regmatch; | 979 regmatch_T regmatch; |
971 | 980 |
972 regmatch.regprog = vim_regcomp(prev_flp, | 981 regmatch.regprog = vim_regcomp(prev_flp, |
973 RE_MAGIC + RE_STRING + RE_AUTO + RE_STRICT); | 982 RE_MAGIC + RE_STRING + RE_AUTO + RE_STRICT); |
984 } | 993 } |
985 vim_regfree(regmatch.regprog); | 994 vim_regfree(regmatch.regprog); |
986 } | 995 } |
987 } | 996 } |
988 } | 997 } |
989 bri = prev_indent + wp->w_briopt_shift; | 998 if (wp->w_briopt_vcol != 0) |
999 { | |
1000 // column value has priority | |
1001 bri = wp->w_briopt_vcol; | |
1002 prev_list = 0; | |
1003 } | |
1004 else | |
1005 bri = prev_indent + wp->w_briopt_shift; | |
990 | 1006 |
991 // Add offset for number column, if 'n' is in 'cpoptions' | 1007 // Add offset for number column, if 'n' is in 'cpoptions' |
992 bri += win_col_off2(wp); | 1008 bri += win_col_off2(wp); |
993 | 1009 |
994 // add additional indent for numbered lists | 1010 // add additional indent for numbered lists |