comparison src/ops.c @ 3584:443c50cd3e88 v7.3.552

updated for version 7.3.552 Problem: Formatting inside comments does not use the "2" flag in 'formatoptions'. Solution: Support the "2" flag. (Tor Perkins)
author Bram Moolenaar <bram@vim.org>
date Wed, 13 Jun 2012 17:28:55 +0200
parents 297771eff080
children 802b1a1b275f
comparison
equal deleted inserted replaced
3583:88a2cac374ea 3584:443c50cd3e88
1725 1725
1726 /* Yank into small delete register when no named register specified 1726 /* Yank into small delete register when no named register specified
1727 * and the delete is within one line. */ 1727 * and the delete is within one line. */
1728 if (( 1728 if ((
1729 #ifdef FEAT_CLIPBOARD 1729 #ifdef FEAT_CLIPBOARD
1730 ((clip_unnamed & CLIP_UNNAMED) && oap->regname == '*') || 1730 ((clip_unnamed & CLIP_UNNAMED) && oap->regname == '*') ||
1731 ((clip_unnamed & CLIP_UNNAMED_PLUS) && oap->regname == '+') || 1731 ((clip_unnamed & CLIP_UNNAMED_PLUS) && oap->regname == '+') ||
1732 #endif 1732 #endif
1733 oap->regname == 0) && oap->motion_type != MLINE 1733 oap->regname == 0) && oap->motion_type != MLINE
1734 && oap->line_count == 1) 1734 && oap->line_count == 1)
1735 { 1735 {
1736 oap->regname = '-'; 1736 oap->regname = '-';
4206 * after some white space), return a pointer to the text after it. Put a boolean 4206 * after some white space), return a pointer to the text after it. Put a boolean
4207 * value indicating whether the line ends with an unclosed comment in 4207 * value indicating whether the line ends with an unclosed comment in
4208 * "is_comment". 4208 * "is_comment".
4209 * line - line to be processed, 4209 * line - line to be processed,
4210 * process - if FALSE, will only check whether the line ends with an unclosed 4210 * process - if FALSE, will only check whether the line ends with an unclosed
4211 * comment, 4211 * comment,
4212 * include_space - whether to also skip space following the comment leader, 4212 * include_space - whether to also skip space following the comment leader,
4213 * is_comment - will indicate whether the current line ends with an unclosed 4213 * is_comment - will indicate whether the current line ends with an unclosed
4214 * comment. 4214 * comment.
4215 */ 4215 */
4216 static char_u * 4216 static char_u *
4217 skip_comment(line, process, include_space, is_comment) 4217 skip_comment(line, process, include_space, is_comment)
4218 char_u *line; 4218 char_u *line;
4219 int process; 4219 int process;
4721 int leader_len = 0; /* leader len of current line */ 4721 int leader_len = 0; /* leader len of current line */
4722 int next_leader_len; /* leader len of next line */ 4722 int next_leader_len; /* leader len of next line */
4723 char_u *leader_flags = NULL; /* flags for leader of current line */ 4723 char_u *leader_flags = NULL; /* flags for leader of current line */
4724 char_u *next_leader_flags; /* flags for leader of next line */ 4724 char_u *next_leader_flags; /* flags for leader of next line */
4725 int do_comments; /* format comments */ 4725 int do_comments; /* format comments */
4726 int do_comments_list = 0; /* format comments with 'n' or '2' */
4726 #endif 4727 #endif
4727 int advance = TRUE; 4728 int advance = TRUE;
4728 int second_indent = -1; 4729 int second_indent = -1; /* indent for second line (comment
4730 * aware) */
4729 int do_second_indent; 4731 int do_second_indent;
4730 int do_number_indent; 4732 int do_number_indent;
4731 int do_trail_white; 4733 int do_trail_white;
4732 int first_par_line = TRUE; 4734 int first_par_line = TRUE;
4733 int smd_save; 4735 int smd_save;
4826 * Don't do this for comments and empty lines. 4828 * Don't do this for comments and empty lines.
4827 */ 4829 */
4828 if (first_par_line 4830 if (first_par_line
4829 && (do_second_indent || do_number_indent) 4831 && (do_second_indent || do_number_indent)
4830 && prev_is_end_par 4832 && prev_is_end_par
4831 && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count 4833 && curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count)
4834 {
4835 if (do_second_indent && !lineempty(curwin->w_cursor.lnum + 1))
4836 {
4832 #ifdef FEAT_COMMENTS 4837 #ifdef FEAT_COMMENTS
4833 && leader_len == 0 4838 if (leader_len == 0 && next_leader_len == 0)
4834 && next_leader_len == 0 4839 {
4835 #endif 4840 /* no comment found */
4836 ) 4841 #endif
4837 { 4842 second_indent =
4838 if (do_second_indent 4843 get_indent_lnum(curwin->w_cursor.lnum + 1);
4839 && !lineempty(curwin->w_cursor.lnum + 1)) 4844 #ifdef FEAT_COMMENTS
4840 second_indent = get_indent_lnum(curwin->w_cursor.lnum + 1); 4845 }
4846 else
4847 {
4848 second_indent = next_leader_len;
4849 do_comments_list = 1;
4850 }
4851 #endif
4852 }
4841 else if (do_number_indent) 4853 else if (do_number_indent)
4842 second_indent = get_number_indent(curwin->w_cursor.lnum); 4854 {
4855 #ifdef FEAT_COMMENTS
4856 if (leader_len == 0 && next_leader_len == 0)
4857 {
4858 /* no comment found */
4859 #endif
4860 second_indent =
4861 get_number_indent(curwin->w_cursor.lnum);
4862 #ifdef FEAT_COMMENTS
4863 }
4864 else
4865 {
4866 /* get_number_indent() is now "comment aware"... */
4867 second_indent =
4868 get_number_indent(curwin->w_cursor.lnum);
4869 do_comments_list = 1;
4870 }
4871 #endif
4872 }
4843 } 4873 }
4844 4874
4845 /* 4875 /*
4846 * When the comment leader changes, it's the end of the paragraph. 4876 * When the comment leader changes, it's the end of the paragraph.
4847 */ 4877 */
4876 smd_save = p_smd; 4906 smd_save = p_smd;
4877 p_smd = FALSE; 4907 p_smd = FALSE;
4878 insertchar(NUL, INSCHAR_FORMAT 4908 insertchar(NUL, INSCHAR_FORMAT
4879 #ifdef FEAT_COMMENTS 4909 #ifdef FEAT_COMMENTS
4880 + (do_comments ? INSCHAR_DO_COM : 0) 4910 + (do_comments ? INSCHAR_DO_COM : 0)
4911 + (do_comments && do_comments_list
4912 ? INSCHAR_COM_LIST : 0)
4881 #endif 4913 #endif
4882 + (avoid_fex ? INSCHAR_NO_FEX : 0), second_indent); 4914 + (avoid_fex ? INSCHAR_NO_FEX : 0), second_indent);
4883 State = old_State; 4915 State = old_State;
4884 p_smd = smd_save; 4916 p_smd = smd_save;
4885 second_indent = -1; 4917 second_indent = -1;