Mercurial > vim
comparison src/edit.c @ 14276:752ef53d3731 v8.1.0154
patch 8.1.0154: crash with "set smarttab shiftwidth=0 softtabstop=-1"
commit https://github.com/vim/vim/commit/c9fe5ab3b093803b6e8d03358ba16aca6b6f0db1
Author: Bram Moolenaar <Bram@vim.org>
Date: Thu Jul 5 22:27:08 2018 +0200
patch 8.1.0154: crash with "set smarttab shiftwidth=0 softtabstop=-1"
Problem: Crash with "set smarttab shiftwidth=0 softtabstop=-1".
Solution: Fall back to using 'tabstop'. (closes https://github.com/vim/vim/issues/3155)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Thu, 05 Jul 2018 22:30:06 +0200 |
parents | fbf0681606fa |
children | 3c80092eb211 |
comparison
equal
deleted
inserted
replaced
14275:2c3c953cf503 | 14276:752ef53d3731 |
---|---|
9345 && (*(ml_get_cursor() - 1) == TAB | 9345 && (*(ml_get_cursor() - 1) == TAB |
9346 || (*(ml_get_cursor() - 1) == ' ' | 9346 || (*(ml_get_cursor() - 1) == ' ' |
9347 && (!*inserted_space_p | 9347 && (!*inserted_space_p |
9348 || arrow_used)))))) | 9348 || arrow_used)))))) |
9349 { | 9349 { |
9350 #ifndef FEAT_VARTABS | |
9351 int ts; | 9350 int ts; |
9352 #endif | |
9353 colnr_T vcol; | 9351 colnr_T vcol; |
9354 colnr_T want_vcol; | 9352 colnr_T want_vcol; |
9355 colnr_T start_vcol; | 9353 colnr_T start_vcol; |
9356 | 9354 |
9357 *inserted_space_p = FALSE; | 9355 *inserted_space_p = FALSE; |
9358 #ifndef FEAT_VARTABS | |
9359 if (p_sta && in_indent) | |
9360 ts = (int)get_sw_value(curbuf); | |
9361 else | |
9362 ts = (int)get_sts_value(); | |
9363 #endif | |
9364 /* Compute the virtual column where we want to be. Since | 9356 /* Compute the virtual column where we want to be. Since |
9365 * 'showbreak' may get in the way, need to get the last column of | 9357 * 'showbreak' may get in the way, need to get the last column of |
9366 * the previous character. */ | 9358 * the previous character. */ |
9367 getvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL); | 9359 getvcol(curwin, &curwin->w_cursor, &vcol, NULL, NULL); |
9368 start_vcol = vcol; | 9360 start_vcol = vcol; |
9369 dec_cursor(); | 9361 dec_cursor(); |
9370 getvcol(curwin, &curwin->w_cursor, NULL, NULL, &want_vcol); | 9362 getvcol(curwin, &curwin->w_cursor, NULL, NULL, &want_vcol); |
9371 inc_cursor(); | 9363 inc_cursor(); |
9372 #ifdef FEAT_VARTABS | 9364 #ifdef FEAT_VARTABS |
9373 if (p_sta && in_indent) | 9365 if (p_sta && in_indent) |
9374 want_vcol = (want_vcol / curbuf->b_p_sw) * curbuf->b_p_sw; | 9366 { |
9367 ts = (int)get_sw_value(curbuf); | |
9368 want_vcol = (want_vcol / ts) * ts; | |
9369 } | |
9375 else | 9370 else |
9376 want_vcol = tabstop_start(want_vcol, get_sts_value(), | 9371 want_vcol = tabstop_start(want_vcol, get_sts_value(), |
9377 curbuf->b_p_vsts_array); | 9372 curbuf->b_p_vsts_array); |
9378 #else | 9373 #else |
9374 if (p_sta && in_indent) | |
9375 ts = (int)get_sw_value(curbuf); | |
9376 else | |
9377 ts = (int)get_sts_value(); | |
9379 want_vcol = (want_vcol / ts) * ts; | 9378 want_vcol = (want_vcol / ts) * ts; |
9380 #endif | 9379 #endif |
9381 | 9380 |
9382 /* delete characters until we are at or before want_vcol */ | 9381 /* delete characters until we are at or before want_vcol */ |
9383 while (vcol > want_vcol | 9382 while (vcol > want_vcol |
10198 AppendToRedobuff((char_u *)"\t"); | 10197 AppendToRedobuff((char_u *)"\t"); |
10199 | 10198 |
10200 #ifdef FEAT_VARTABS | 10199 #ifdef FEAT_VARTABS |
10201 if (p_sta && ind) /* insert tab in indent, use 'shiftwidth' */ | 10200 if (p_sta && ind) /* insert tab in indent, use 'shiftwidth' */ |
10202 { | 10201 { |
10203 temp = (int)curbuf->b_p_sw; | 10202 temp = (int)get_sw_value(curbuf); |
10204 temp -= get_nolist_virtcol() % temp; | 10203 temp -= get_nolist_virtcol() % temp; |
10205 } | 10204 } |
10206 else if (tabstop_count(curbuf->b_p_vsts_array) > 0 || curbuf->b_p_sts != 0) | 10205 else if (tabstop_count(curbuf->b_p_vsts_array) > 0 || curbuf->b_p_sts != 0) |
10207 /* use 'softtabstop' when set */ | 10206 /* use 'softtabstop' when set */ |
10208 temp = tabstop_padding(get_nolist_virtcol(), get_sts_value(), | 10207 temp = tabstop_padding(get_nolist_virtcol(), get_sts_value(), |