mirror of
https://github.com/neovim/neovim.git
synced 2025-09-14 15:28:17 +00:00
vim-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 vim/vim#3155)
c9fe5ab3b0
This commit is contained in:
@@ -8189,6 +8189,7 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
|
|||||||
&& (*(get_cursor_pos_ptr() - 1) == TAB
|
&& (*(get_cursor_pos_ptr() - 1) == TAB
|
||||||
|| (*(get_cursor_pos_ptr() - 1) == ' '
|
|| (*(get_cursor_pos_ptr() - 1) == ' '
|
||||||
&& (!*inserted_space_p || arrow_used)))))) {
|
&& (!*inserted_space_p || arrow_used)))))) {
|
||||||
|
int ts;
|
||||||
colnr_T vcol;
|
colnr_T vcol;
|
||||||
colnr_T want_vcol;
|
colnr_T want_vcol;
|
||||||
colnr_T start_vcol;
|
colnr_T start_vcol;
|
||||||
@@ -8203,7 +8204,8 @@ static bool ins_bs(int c, int mode, int *inserted_space_p)
|
|||||||
getvcol(curwin, &curwin->w_cursor, NULL, NULL, &want_vcol);
|
getvcol(curwin, &curwin->w_cursor, NULL, NULL, &want_vcol);
|
||||||
inc_cursor();
|
inc_cursor();
|
||||||
if (p_sta && in_indent) {
|
if (p_sta && in_indent) {
|
||||||
want_vcol = (want_vcol / curbuf->b_p_sw) * curbuf->b_p_sw;
|
ts = (int)get_sw_value(curbuf);
|
||||||
|
want_vcol = (want_vcol / ts) * ts;
|
||||||
} else {
|
} else {
|
||||||
want_vcol = tabstop_start(want_vcol,
|
want_vcol = tabstop_start(want_vcol,
|
||||||
get_sts_value(),
|
get_sts_value(),
|
||||||
@@ -8700,7 +8702,7 @@ static bool ins_tab(void)
|
|||||||
AppendToRedobuff("\t");
|
AppendToRedobuff("\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(curbuf);
|
||||||
temp -= get_nolist_virtcol() % temp;
|
temp -= get_nolist_virtcol() % temp;
|
||||||
} else if (tabstop_count(curbuf->b_p_vsts_array) > 0
|
} else if (tabstop_count(curbuf->b_p_vsts_array) > 0
|
||||||
|| curbuf->b_p_sts != 0) {
|
|| curbuf->b_p_sts != 0) {
|
||||||
|
@@ -76,6 +76,15 @@ func Test_softtabstop()
|
|||||||
exe "normal A\<BS>x\<Esc>"
|
exe "normal A\<BS>x\<Esc>"
|
||||||
call assert_equal("x x", getline(1))
|
call assert_equal("x x", getline(1))
|
||||||
|
|
||||||
set sts=0 sw=0 backspace&
|
call setline(1, 'x')
|
||||||
|
set sts=-1 sw=0 smarttab
|
||||||
|
exe "normal I\<Tab>\<Esc>"
|
||||||
|
call assert_equal("\tx", getline(1))
|
||||||
|
|
||||||
|
call setline(1, 'x')
|
||||||
|
exe "normal I\<Tab>\<BS>\<Esc>"
|
||||||
|
call assert_equal("x", getline(1))
|
||||||
|
|
||||||
|
set sts=0 sw=0 backspace& nosmarttab
|
||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
Reference in New Issue
Block a user