diff options
author | VVKot <volodymyr.kot.ua@gmail.com> | 2021-01-31 17:19:39 +0000 |
---|---|---|
committer | VVKot <volodymyr.kot.ua@gmail.com> | 2021-03-28 08:37:04 +0100 |
commit | 2922f6e34bde27fa9788e806f871f50a2b46e6a7 (patch) | |
tree | 9b09adc139127a00ae765b6f5193891089e59c6f | |
parent | 7ee09c61fe536a05e0a5fa88b52c4be50954dfde (diff) | |
download | rneovim-2922f6e34bde27fa9788e806f871f50a2b46e6a7.tar.gz rneovim-2922f6e34bde27fa9788e806f871f50a2b46e6a7.tar.bz2 rneovim-2922f6e34bde27fa9788e806f871f50a2b46e6a7.zip |
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)
https://github.com/vim/vim/commit/307ac5c68e9e624ab713136d79f35bb73f780d2d
-rw-r--r-- | src/nvim/ex_cmds.c | 2 | ||||
-rw-r--r-- | src/nvim/option.c | 7 | ||||
-rw-r--r-- | src/nvim/screen.c | 4 | ||||
-rw-r--r-- | src/nvim/testdir/test_vartabs.vim | 28 |
4 files changed, 32 insertions, 9 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index 00d4513051..d34282419a 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -853,7 +853,6 @@ void ex_retab(exarg_T *eap) if (tabstop_count(old_vts_ary) > 0 || tabstop_count(new_vts_array) > 1) { set_string_option_direct("vts", -1, new_ts_str, OPT_FREE | OPT_LOCAL, 0); - xfree(new_ts_str); curbuf->b_p_vts_array = new_vts_array; xfree(old_vts_ary); } else { @@ -862,6 +861,7 @@ void ex_retab(exarg_T *eap) curbuf->b_p_ts = tabstop_first(new_vts_array); xfree(new_vts_array); } + xfree(new_ts_str); } coladvance(curwin->w_curswant); diff --git a/src/nvim/option.c b/src/nvim/option.c index fc3771f42b..2a09c664dd 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -7215,7 +7215,7 @@ colnr_T tabstop_start(colnr_T col, long ts, long *vts) // to another. void tabstop_fromto(colnr_T start_col, colnr_T end_col, - long ts, + long ts_arg, long *vts, int *ntabs, int *nspcs) @@ -7225,10 +7225,13 @@ void tabstop_fromto(colnr_T start_col, int padding = 0; int tabcount; int t; + long ts = ts_arg == 0 ? curbuf->b_p_ts : ts_arg; if (vts == NULL || vts[0] == 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) { spaces -= initspc; tabs++; diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 2b664cf5b0..7c71a440af 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -3543,6 +3543,10 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, xfree(p_extra_free); p_extra_free = p; for (i = 0; i < tab_len; i++) { + if (*p == NUL) { + tab_len = i; + break; + } int lcs = wp->w_p_lcs_chars.tab2; // if tab3 is given, need to change the char diff --git a/src/nvim/testdir/test_vartabs.vim b/src/nvim/testdir/test_vartabs.vim index 581ff8b9bb..c43e178309 100644 --- a/src/nvim/testdir/test_vartabs.vim +++ b/src/nvim/testdir/test_vartabs.vim @@ -262,21 +262,37 @@ func! Test_vartabs_breakindent() endfunc func! Test_vartabs_linebreak() - if winwidth(0) < 80 + if winwidth(0) < 40 return endif new - 70vnew + 40vnew %d - setl linebreak vartabstop=10,15,20,40 + setl linebreak vartabstop=10,20,30,40 call setline(1, "\tx\tx\tx\tx") - let lines = ScreenLines([1, 2], winwidth(0)) - let expect = [' x x x ', - \ ' x '] + let expect = [' 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) " cleanup bw! bw! + set nolist listchars&vim endfunc |