mirror of
https://github.com/vim/vim.git
synced 2025-07-24 10:45:12 -04:00
updated for version 7.3.629
Problem: There is no way to make 'shiftwidth' follow 'tabstop'. Solution: When 'shiftwidth' is zero use the value of 'tabstop'. (Christian Brabandt)
This commit is contained in:
parent
b02612b641
commit
14f2474147
@ -8899,9 +8899,9 @@ ins_bs(c, mode, inserted_space_p)
|
|||||||
|
|
||||||
*inserted_space_p = FALSE;
|
*inserted_space_p = FALSE;
|
||||||
if (p_sta && in_indent)
|
if (p_sta && in_indent)
|
||||||
ts = curbuf->b_p_sw;
|
ts = (int)get_sw_value();
|
||||||
else
|
else
|
||||||
ts = curbuf->b_p_sts;
|
ts = (int)curbuf->b_p_sts;
|
||||||
/* Compute the virtual column where we want to be. Since
|
/* Compute the virtual column where we want to be. Since
|
||||||
* 'showbreak' may get in the way, need to get the last column of
|
* 'showbreak' may get in the way, need to get the last column of
|
||||||
* the previous character. */
|
* the previous character. */
|
||||||
@ -9589,7 +9589,7 @@ ins_tab()
|
|||||||
* When nothing special, insert TAB like a normal character
|
* When nothing special, insert TAB like a normal character
|
||||||
*/
|
*/
|
||||||
if (!curbuf->b_p_et
|
if (!curbuf->b_p_et
|
||||||
&& !(p_sta && ind && curbuf->b_p_ts != curbuf->b_p_sw)
|
&& !(p_sta && ind && curbuf->b_p_ts != get_sw_value())
|
||||||
&& curbuf->b_p_sts == 0)
|
&& curbuf->b_p_sts == 0)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
@ -9605,7 +9605,7 @@ ins_tab()
|
|||||||
AppendToRedobuff((char_u *)"\t");
|
AppendToRedobuff((char_u *)"\t");
|
||||||
|
|
||||||
if (p_sta && ind) /* insert tab in indent, use 'shiftwidth' */
|
if (p_sta && ind) /* insert tab in indent, use 'shiftwidth' */
|
||||||
temp = (int)curbuf->b_p_sw;
|
temp = (int)get_sw_value();
|
||||||
else if (curbuf->b_p_sts > 0) /* use 'softtabstop' when set */
|
else if (curbuf->b_p_sts > 0) /* use 'softtabstop' when set */
|
||||||
temp = (int)curbuf->b_p_sts;
|
temp = (int)curbuf->b_p_sts;
|
||||||
else /* otherwise use 'tabstop' */
|
else /* otherwise use 'tabstop' */
|
||||||
|
@ -2268,10 +2268,12 @@ getexmodeline(promptc, cookie, indent)
|
|||||||
|
|
||||||
if (c1 == Ctrl_T)
|
if (c1 == Ctrl_T)
|
||||||
{
|
{
|
||||||
|
long sw = get_sw_value();
|
||||||
|
|
||||||
p = (char_u *)line_ga.ga_data;
|
p = (char_u *)line_ga.ga_data;
|
||||||
p[line_ga.ga_len] = NUL;
|
p[line_ga.ga_len] = NUL;
|
||||||
indent = get_indent_str(p, 8);
|
indent = get_indent_str(p, 8);
|
||||||
indent += curbuf->b_p_sw - indent % curbuf->b_p_sw;
|
indent += sw - indent % sw;
|
||||||
add_indent:
|
add_indent:
|
||||||
while (get_indent_str(p, 8) < indent)
|
while (get_indent_str(p, 8) < indent)
|
||||||
{
|
{
|
||||||
@ -2323,7 +2325,7 @@ redraw:
|
|||||||
p[line_ga.ga_len] = NUL;
|
p[line_ga.ga_len] = NUL;
|
||||||
indent = get_indent_str(p, 8);
|
indent = get_indent_str(p, 8);
|
||||||
--indent;
|
--indent;
|
||||||
indent -= indent % curbuf->b_p_sw;
|
indent -= indent % get_sw_value();
|
||||||
}
|
}
|
||||||
while (get_indent_str(p, 8) > indent)
|
while (get_indent_str(p, 8) > indent)
|
||||||
{
|
{
|
||||||
|
@ -3025,7 +3025,7 @@ foldlevelIndent(flp)
|
|||||||
flp->lvl = -1;
|
flp->lvl = -1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
flp->lvl = get_indent_buf(buf, lnum) / buf->b_p_sw;
|
flp->lvl = get_indent_buf(buf, lnum) / get_sw_value();
|
||||||
if (flp->lvl > flp->wp->w_p_fdn)
|
if (flp->lvl > flp->wp->w_p_fdn)
|
||||||
{
|
{
|
||||||
flp->lvl = flp->wp->w_p_fdn;
|
flp->lvl = flp->wp->w_p_fdn;
|
||||||
|
37
src/misc1.c
37
src/misc1.c
@ -1389,9 +1389,11 @@ open_line(dir, flags, second_line_indent)
|
|||||||
#ifdef FEAT_SMARTINDENT
|
#ifdef FEAT_SMARTINDENT
|
||||||
if (did_si)
|
if (did_si)
|
||||||
{
|
{
|
||||||
|
int sw = (int)get_sw_value();
|
||||||
|
|
||||||
if (p_sr)
|
if (p_sr)
|
||||||
newindent -= newindent % (int)curbuf->b_p_sw;
|
newindent -= newindent % sw;
|
||||||
newindent += (int)curbuf->b_p_sw;
|
newindent += sw;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* Copy the indent */
|
/* Copy the indent */
|
||||||
@ -6461,11 +6463,14 @@ find_last_paren(l, start, end)
|
|||||||
int
|
int
|
||||||
get_c_indent()
|
get_c_indent()
|
||||||
{
|
{
|
||||||
|
int sw = (int)get_sw_value();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* spaces from a block's opening brace the prevailing indent for that
|
* spaces from a block's opening brace the prevailing indent for that
|
||||||
* block should be
|
* block should be
|
||||||
*/
|
*/
|
||||||
int ind_level = curbuf->b_p_sw;
|
|
||||||
|
int ind_level = sw;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* spaces from the edge of the line an open brace that's at the end of a
|
* spaces from the edge of the line an open brace that's at the end of a
|
||||||
@ -6512,12 +6517,12 @@ get_c_indent()
|
|||||||
/*
|
/*
|
||||||
* spaces from the switch() indent a "case xx" label should be located
|
* spaces from the switch() indent a "case xx" label should be located
|
||||||
*/
|
*/
|
||||||
int ind_case = curbuf->b_p_sw;
|
int ind_case = sw;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* spaces from the "case xx:" code after a switch() should be located
|
* spaces from the "case xx:" code after a switch() should be located
|
||||||
*/
|
*/
|
||||||
int ind_case_code = curbuf->b_p_sw;
|
int ind_case_code = sw;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* lineup break at end of case in switch() with case label
|
* lineup break at end of case in switch() with case label
|
||||||
@ -6528,45 +6533,45 @@ get_c_indent()
|
|||||||
* spaces from the class declaration indent a scope declaration label
|
* spaces from the class declaration indent a scope declaration label
|
||||||
* should be located
|
* should be located
|
||||||
*/
|
*/
|
||||||
int ind_scopedecl = curbuf->b_p_sw;
|
int ind_scopedecl = sw;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* spaces from the scope declaration label code should be located
|
* spaces from the scope declaration label code should be located
|
||||||
*/
|
*/
|
||||||
int ind_scopedecl_code = curbuf->b_p_sw;
|
int ind_scopedecl_code = sw;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* amount K&R-style parameters should be indented
|
* amount K&R-style parameters should be indented
|
||||||
*/
|
*/
|
||||||
int ind_param = curbuf->b_p_sw;
|
int ind_param = sw;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* amount a function type spec should be indented
|
* amount a function type spec should be indented
|
||||||
*/
|
*/
|
||||||
int ind_func_type = curbuf->b_p_sw;
|
int ind_func_type = sw;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* amount a cpp base class declaration or constructor initialization
|
* amount a cpp base class declaration or constructor initialization
|
||||||
* should be indented
|
* should be indented
|
||||||
*/
|
*/
|
||||||
int ind_cpp_baseclass = curbuf->b_p_sw;
|
int ind_cpp_baseclass = sw;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* additional spaces beyond the prevailing indent a continuation line
|
* additional spaces beyond the prevailing indent a continuation line
|
||||||
* should be located
|
* should be located
|
||||||
*/
|
*/
|
||||||
int ind_continuation = curbuf->b_p_sw;
|
int ind_continuation = sw;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* spaces from the indent of the line with an unclosed parentheses
|
* spaces from the indent of the line with an unclosed parentheses
|
||||||
*/
|
*/
|
||||||
int ind_unclosed = curbuf->b_p_sw * 2;
|
int ind_unclosed = sw * 2;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* spaces from the indent of the line with an unclosed parentheses, which
|
* spaces from the indent of the line with an unclosed parentheses, which
|
||||||
* itself is also unclosed
|
* itself is also unclosed
|
||||||
*/
|
*/
|
||||||
int ind_unclosed2 = curbuf->b_p_sw;
|
int ind_unclosed2 = sw;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* suppress ignoring spaces from the indent of a line starting with an
|
* suppress ignoring spaces from the indent of a line starting with an
|
||||||
@ -6719,12 +6724,12 @@ get_c_indent()
|
|||||||
if (*options == 's') /* "2s" means two times 'shiftwidth' */
|
if (*options == 's') /* "2s" means two times 'shiftwidth' */
|
||||||
{
|
{
|
||||||
if (options == digits)
|
if (options == digits)
|
||||||
n = curbuf->b_p_sw; /* just "s" is one 'shiftwidth' */
|
n = sw; /* just "s" is one 'shiftwidth' */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
n *= curbuf->b_p_sw;
|
n *= sw;
|
||||||
if (divider)
|
if (divider)
|
||||||
n += (curbuf->b_p_sw * fraction + divider / 2) / divider;
|
n += (sw * fraction + divider / 2) / divider;
|
||||||
}
|
}
|
||||||
++options;
|
++options;
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,7 @@ shift_line(left, round, amount, call_changed_bytes)
|
|||||||
{
|
{
|
||||||
int count;
|
int count;
|
||||||
int i, j;
|
int i, j;
|
||||||
int p_sw = (int)curbuf->b_p_sw;
|
int p_sw = (int)get_sw_value();
|
||||||
|
|
||||||
count = get_indent(); /* get current indent */
|
count = get_indent(); /* get current indent */
|
||||||
|
|
||||||
@ -388,7 +388,7 @@ shift_block(oap, amount)
|
|||||||
int total;
|
int total;
|
||||||
char_u *newp, *oldp;
|
char_u *newp, *oldp;
|
||||||
int oldcol = curwin->w_cursor.col;
|
int oldcol = curwin->w_cursor.col;
|
||||||
int p_sw = (int)curbuf->b_p_sw;
|
int p_sw = (int)get_sw_value();
|
||||||
int p_ts = (int)curbuf->b_p_ts;
|
int p_ts = (int)curbuf->b_p_ts;
|
||||||
struct block_def bd;
|
struct block_def bd;
|
||||||
int incr;
|
int incr;
|
||||||
|
12
src/option.c
12
src/option.c
@ -8125,7 +8125,7 @@ set_num_option(opt_idx, varp, value, errbuf, errbuflen, opt_flags)
|
|||||||
need_mouse_correct = TRUE;
|
need_mouse_correct = TRUE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (curbuf->b_p_sw <= 0)
|
if (curbuf->b_p_sw < 0)
|
||||||
{
|
{
|
||||||
errmsg = e_positive;
|
errmsg = e_positive;
|
||||||
curbuf->b_p_sw = curbuf->b_p_ts;
|
curbuf->b_p_sw = curbuf->b_p_ts;
|
||||||
@ -11419,3 +11419,13 @@ check_ff_value(p)
|
|||||||
{
|
{
|
||||||
return check_opt_strings(p, p_ff_values, FALSE);
|
return check_opt_strings(p, p_ff_values, FALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Return the effective shiftwidth value for current buffer, using the
|
||||||
|
* 'tabstop' value when 'shiftwidth' is zero.
|
||||||
|
*/
|
||||||
|
long
|
||||||
|
get_sw_value()
|
||||||
|
{
|
||||||
|
return curbuf->b_p_sw ? curbuf->b_p_sw : curbuf->b_p_ts;
|
||||||
|
}
|
||||||
|
@ -56,4 +56,5 @@ int can_bs __ARGS((int what));
|
|||||||
void save_file_ff __ARGS((buf_T *buf));
|
void save_file_ff __ARGS((buf_T *buf));
|
||||||
int file_ff_differs __ARGS((buf_T *buf, int ignore_empty));
|
int file_ff_differs __ARGS((buf_T *buf, int ignore_empty));
|
||||||
int check_ff_value __ARGS((char_u *p));
|
int check_ff_value __ARGS((char_u *p));
|
||||||
|
long get_sw_value __ARGS((void));
|
||||||
/* vim: set ft=c : */
|
/* vim: set ft=c : */
|
||||||
|
@ -714,6 +714,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
629,
|
||||||
/**/
|
/**/
|
||||||
628,
|
628,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user