comparison src/edit.c @ 15440:5ecac7734184 v8.1.0728

patch 8.1.0728: cannot avoid breaking after a single space. commit https://github.com/vim/vim/commit/c3c3158756ae074052b0db2a3e3a7ba192df5330 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Jan 11 22:15:05 2019 +0100 patch 8.1.0728: cannot avoid breaking after a single space. Problem: Cannot avoid breaking after a single space. Solution: Add the 'p' flag to 'formatoptions'. (Tom Ryder)
author Bram Moolenaar <Bram@vim.org>
date Fri, 11 Jan 2019 22:30:06 +0100
parents 29f3d59bb6f0
children 55ccc2d353bd
comparison
equal deleted inserted replaced
15439:ffcd5473738f 15440:5ecac7734184
6496 colnr_T virtcol; 6496 colnr_T virtcol;
6497 int orig_col = 0; 6497 int orig_col = 0;
6498 char_u *saved_text = NULL; 6498 char_u *saved_text = NULL;
6499 colnr_T col; 6499 colnr_T col;
6500 colnr_T end_col; 6500 colnr_T end_col;
6501 int wcc; // counter for whitespace chars
6501 6502
6502 virtcol = get_nolist_virtcol() 6503 virtcol = get_nolist_virtcol()
6503 + char2cells(c != NUL ? c : gchar_cursor()); 6504 + char2cells(c != NUL ? c : gchar_cursor());
6504 if (virtcol <= (colnr_T)textwidth) 6505 if (virtcol <= (colnr_T)textwidth)
6505 break; 6506 break;
6557 if (WHITECHAR(cc)) 6558 if (WHITECHAR(cc))
6558 { 6559 {
6559 /* remember position of blank just before text */ 6560 /* remember position of blank just before text */
6560 end_col = curwin->w_cursor.col; 6561 end_col = curwin->w_cursor.col;
6561 6562
6562 /* find start of sequence of blanks */ 6563 // find start of sequence of blanks
6564 wcc = 0;
6563 while (curwin->w_cursor.col > 0 && WHITECHAR(cc)) 6565 while (curwin->w_cursor.col > 0 && WHITECHAR(cc))
6564 { 6566 {
6565 dec_cursor(); 6567 dec_cursor();
6566 cc = gchar_cursor(); 6568 cc = gchar_cursor();
6569
6570 // Increment count of how many whitespace chars in this
6571 // group; we only need to know if it's more than one.
6572 if (wcc < 2)
6573 wcc++;
6567 } 6574 }
6568 if (curwin->w_cursor.col == 0 && WHITECHAR(cc)) 6575 if (curwin->w_cursor.col == 0 && WHITECHAR(cc))
6569 break; /* only spaces in front of text */ 6576 break; /* only spaces in front of text */
6577
6578 // Don't break after a period when 'formatoptions' has 'p' and
6579 // there are less than two spaces.
6580 if (has_format_option(FO_PERIOD_ABBR) && cc == '.' && wcc < 2)
6581 continue;
6582
6570 #ifdef FEAT_COMMENTS 6583 #ifdef FEAT_COMMENTS
6571 /* Don't break until after the comment leader */ 6584 /* Don't break until after the comment leader */
6572 if (curwin->w_cursor.col < leader_len) 6585 if (curwin->w_cursor.col < leader_len)
6573 break; 6586 break;
6574 #endif 6587 #endif