mirror of
https://github.com/neovim/neovim.git
synced 2025-09-22 19:18:34 +00:00
vim-patch:8.1.0126: various problems with 'vartabstop'
Problem: Various problems with 'vartabstop'.
Solution: Fix memory leak. Fix crash. Add a few more tests. (Christian
Brabandt, closes vim/vim#3076)
307ac5c68e
This commit is contained in:
@@ -853,7 +853,6 @@ void ex_retab(exarg_T *eap)
|
|||||||
if (tabstop_count(old_vts_ary) > 0 || tabstop_count(new_vts_array) > 1) {
|
if (tabstop_count(old_vts_ary) > 0 || tabstop_count(new_vts_array) > 1) {
|
||||||
set_string_option_direct("vts", -1, new_ts_str,
|
set_string_option_direct("vts", -1, new_ts_str,
|
||||||
OPT_FREE | OPT_LOCAL, 0);
|
OPT_FREE | OPT_LOCAL, 0);
|
||||||
xfree(new_ts_str);
|
|
||||||
curbuf->b_p_vts_array = new_vts_array;
|
curbuf->b_p_vts_array = new_vts_array;
|
||||||
xfree(old_vts_ary);
|
xfree(old_vts_ary);
|
||||||
} else {
|
} else {
|
||||||
@@ -862,6 +861,7 @@ void ex_retab(exarg_T *eap)
|
|||||||
curbuf->b_p_ts = tabstop_first(new_vts_array);
|
curbuf->b_p_ts = tabstop_first(new_vts_array);
|
||||||
xfree(new_vts_array);
|
xfree(new_vts_array);
|
||||||
}
|
}
|
||||||
|
xfree(new_ts_str);
|
||||||
}
|
}
|
||||||
coladvance(curwin->w_curswant);
|
coladvance(curwin->w_curswant);
|
||||||
|
|
||||||
|
@@ -7215,7 +7215,7 @@ colnr_T tabstop_start(colnr_T col, long ts, long *vts)
|
|||||||
// to another.
|
// to another.
|
||||||
void tabstop_fromto(colnr_T start_col,
|
void tabstop_fromto(colnr_T start_col,
|
||||||
colnr_T end_col,
|
colnr_T end_col,
|
||||||
long ts,
|
long ts_arg,
|
||||||
long *vts,
|
long *vts,
|
||||||
int *ntabs,
|
int *ntabs,
|
||||||
int *nspcs)
|
int *nspcs)
|
||||||
@@ -7225,10 +7225,13 @@ void tabstop_fromto(colnr_T start_col,
|
|||||||
int padding = 0;
|
int padding = 0;
|
||||||
int tabcount;
|
int tabcount;
|
||||||
int t;
|
int t;
|
||||||
|
long ts = ts_arg == 0 ? curbuf->b_p_ts : ts_arg;
|
||||||
|
|
||||||
if (vts == NULL || vts[0] == 0) {
|
if (vts == NULL || vts[0] == 0) {
|
||||||
int tabs = 0;
|
int tabs = 0;
|
||||||
int initspc = (int)ts - (start_col % (int)ts);
|
int initspc = 0;
|
||||||
|
|
||||||
|
initspc = (int)ts - (start_col % (int)ts);
|
||||||
if (spaces >= initspc) {
|
if (spaces >= initspc) {
|
||||||
spaces -= initspc;
|
spaces -= initspc;
|
||||||
tabs++;
|
tabs++;
|
||||||
|
@@ -3543,6 +3543,10 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow,
|
|||||||
xfree(p_extra_free);
|
xfree(p_extra_free);
|
||||||
p_extra_free = p;
|
p_extra_free = p;
|
||||||
for (i = 0; i < tab_len; i++) {
|
for (i = 0; i < tab_len; i++) {
|
||||||
|
if (*p == NUL) {
|
||||||
|
tab_len = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
int lcs = wp->w_p_lcs_chars.tab2;
|
int lcs = wp->w_p_lcs_chars.tab2;
|
||||||
|
|
||||||
// if tab3 is given, need to change the char
|
// if tab3 is given, need to change the char
|
||||||
|
@@ -262,21 +262,37 @@ func! Test_vartabs_breakindent()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func! Test_vartabs_linebreak()
|
func! Test_vartabs_linebreak()
|
||||||
if winwidth(0) < 80
|
if winwidth(0) < 40
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
new
|
new
|
||||||
70vnew
|
40vnew
|
||||||
%d
|
%d
|
||||||
setl linebreak vartabstop=10,15,20,40
|
setl linebreak vartabstop=10,20,30,40
|
||||||
call setline(1, "\tx\tx\tx\tx")
|
call setline(1, "\tx\tx\tx\tx")
|
||||||
|
|
||||||
let lines = ScreenLines([1, 2], winwidth(0))
|
let expect = [' x ',
|
||||||
let expect = [' x x x ',
|
\ 'x x ',
|
||||||
\ 'x ']
|
\ 'x ']
|
||||||
|
let lines = ScreenLines([1, 3], winwidth(0))
|
||||||
|
call s:compare_lines(expect, lines)
|
||||||
|
setl list listchars=tab:>-
|
||||||
|
let expect = ['>---------x>------------------ ',
|
||||||
|
\ 'x>------------------x>------------------',
|
||||||
|
\ 'x ']
|
||||||
|
let lines = ScreenLines([1, 3], winwidth(0))
|
||||||
|
call s:compare_lines(expect, lines)
|
||||||
|
setl linebreak vartabstop=40
|
||||||
|
let expect = ['>---------------------------------------',
|
||||||
|
\ 'x>--------------------------------------',
|
||||||
|
\ 'x>--------------------------------------',
|
||||||
|
\ 'x>--------------------------------------',
|
||||||
|
\ 'x ']
|
||||||
|
let lines = ScreenLines([1, 5], winwidth(0))
|
||||||
call s:compare_lines(expect, lines)
|
call s:compare_lines(expect, lines)
|
||||||
|
|
||||||
" cleanup
|
" cleanup
|
||||||
bw!
|
bw!
|
||||||
bw!
|
bw!
|
||||||
|
set nolist listchars&vim
|
||||||
endfunc
|
endfunc
|
||||||
|
Reference in New Issue
Block a user