comparison src/drawline.c @ 33536:886e7c8f7614 v9.0.2017

patch 9.0.2017: linebreak applies for leading whitespace Commit: https://github.com/vim/vim/commit/dd75fcfbdff1934c6e531b5a89ebc636318bf4a2 Author: Christian Brabandt <cb@256bit.org> Date: Wed Oct 11 21:51:19 2023 +0200 patch 9.0.2017: linebreak applies for leading whitespace Problem: linebreak applies for leading whitespace Solution: only apply linebreak, once we have found non-breakat chars in the line closes: #13228 closes: #13243 Signed-off-by: Christian Brabandt <cb@256bit.org>
author Christian Brabandt <cb@256bit.org>
date Wed, 11 Oct 2023 22:00:05 +0200
parents e385bda5e345
children 25e5297fbc72
comparison
equal deleted inserted replaced
33535:ac78267a29de 33536:886e7c8f7614
168 #endif 168 #endif
169 int filler_lines; // nr of filler lines to be drawn 169 int filler_lines; // nr of filler lines to be drawn
170 int filler_todo; // nr of filler lines still to do + 1 170 int filler_todo; // nr of filler lines still to do + 1
171 #ifdef FEAT_SIGNS 171 #ifdef FEAT_SIGNS
172 sign_attrs_T sattr; 172 sign_attrs_T sattr;
173 #endif
174 #ifdef FEAT_LINEBREAK
175 // do consider wrapping in linebreak mode only after encountering
176 // a non whitespace char
177 int need_lbr;
173 #endif 178 #endif
174 } winlinevars_T; 179 } winlinevars_T;
175 180
176 // draw_state values for items that are drawn in sequence: 181 // draw_state values for items that are drawn in sequence:
177 #define WL_START 0 // nothing done yet, must be zero 182 #define WL_START 0 // nothing done yet, must be zero
966 static void 971 static void
967 win_line_start(win_T *wp UNUSED, winlinevars_T *wlv, int save_extra) 972 win_line_start(win_T *wp UNUSED, winlinevars_T *wlv, int save_extra)
968 { 973 {
969 wlv->col = 0; 974 wlv->col = 0;
970 wlv->off = (unsigned)(current_ScreenLine - ScreenLines); 975 wlv->off = (unsigned)(current_ScreenLine - ScreenLines);
976 #ifdef FEAT_LINEBREAK
977 wlv->need_lbr = FALSE;
978 #endif
971 979
972 #ifdef FEAT_RIGHTLEFT 980 #ifdef FEAT_RIGHTLEFT
973 if (wp->w_p_rl) 981 if (wp->w_p_rl)
974 { 982 {
975 // Rightleft window: process the text in the normal direction, but put 983 // Rightleft window: process the text in the normal direction, but put
992 wlv->saved_extra_attr = wlv->extra_attr; 1000 wlv->saved_extra_attr = wlv->extra_attr;
993 wlv->saved_n_attr_skip = wlv->n_attr_skip; 1001 wlv->saved_n_attr_skip = wlv->n_attr_skip;
994 wlv->saved_extra_for_textprop = wlv->extra_for_textprop; 1002 wlv->saved_extra_for_textprop = wlv->extra_for_textprop;
995 wlv->saved_c_extra = wlv->c_extra; 1003 wlv->saved_c_extra = wlv->c_extra;
996 wlv->saved_c_final = wlv->c_final; 1004 wlv->saved_c_final = wlv->c_final;
1005 #ifdef FEAT_LINEBREAK
1006 wlv->need_lbr = TRUE;
1007 #endif
997 #ifdef FEAT_SYN_HL 1008 #ifdef FEAT_SYN_HL
998 if (!(wlv->cul_screenline 1009 if (!(wlv->cul_screenline
999 # ifdef FEAT_DIFF 1010 # ifdef FEAT_DIFF
1000 && wlv->diff_hlf == (hlf_T)0 1011 && wlv->diff_hlf == (hlf_T)0
1001 # endif 1012 # endif
2903 wlv.char_attr = hl_combine_attr(spell_attr, 2914 wlv.char_attr = hl_combine_attr(spell_attr,
2904 wlv.char_attr); 2915 wlv.char_attr);
2905 } 2916 }
2906 #endif 2917 #endif
2907 #ifdef FEAT_LINEBREAK 2918 #ifdef FEAT_LINEBREAK
2919 // we don't want linebreak to apply for lines that start with
2920 // leading spaces, followed by long letters (since it would add
2921 // a break at the beginning of a line and this might be unexpected)
2922 //
2923 // So only allow to linebreak, once we have found chars not in
2924 // 'breakat' in the line.
2925 if ( wp->w_p_lbr && !wlv.need_lbr && c != NUL &&
2926 !VIM_ISBREAK((int)*ptr))
2927 wlv.need_lbr = TRUE;
2928 #endif
2929 #ifdef FEAT_LINEBREAK
2908 // Found last space before word: check for line break. 2930 // Found last space before word: check for line break.
2909 if (wp->w_p_lbr && c0 == c 2931 if (wp->w_p_lbr && c0 == c && wlv.need_lbr
2910 && VIM_ISBREAK(c) && !VIM_ISBREAK((int)*ptr)) 2932 && VIM_ISBREAK(c) && !VIM_ISBREAK((int)*ptr))
2911 { 2933 {
2912 int mb_off = has_mbyte ? (*mb_head_off)(line, ptr - 1) 2934 int mb_off = has_mbyte ? (*mb_head_off)(line, ptr - 1)
2913 : 0; 2935 : 0;
2914 char_u *p = ptr - (mb_off + 1); 2936 char_u *p = ptr - (mb_off + 1);