Fix: #891 Table Pressing <Enter> autosets tw<-0

Issue: Pressing <Enter> in insert mode in table breaks line wrapping #891
This commit is contained in:
Tinmarino 2020-07-21 15:13:58 -04:00
parent 19bfe93ef3
commit dfc5344d0c
2 changed files with 5 additions and 19 deletions

View File

@ -15,9 +15,6 @@ endif
let g:loaded_vimwiki_tbl_auto = 1 let g:loaded_vimwiki_tbl_auto = 1
let s:textwidth = &textwidth
function! s:rxSep() abort function! s:rxSep() abort
return vimwiki#vars#get_syntaxlocal('rxTableSep') return vimwiki#vars#get_syntaxlocal('rxTableSep')
endfunction endfunction
@ -679,6 +676,9 @@ function! vimwiki#tbl#format(lnum, ...) abort
return return
endif endif
" Backup textwidth
let textwidth = &textwidth
let depth = a:0 == 1 ? a:1 : 0 let depth = a:0 == 1 ? a:1 : 0
if a:0 == 2 if a:0 == 2
@ -704,7 +704,8 @@ function! vimwiki#tbl#format(lnum, ...) abort
endif endif
endfor endfor
let &textwidth = s:textwidth " Restore user textwidth
let &textwidth = textwidth
endfunction endfunction
@ -753,20 +754,6 @@ function! vimwiki#tbl#align_or_cmd(cmd, ...) abort
endfunction endfunction
function! vimwiki#tbl#reset_tw(lnum) abort
if !vimwiki#u#ft_is_vw()
return
endif
let line = getline(a:lnum)
if !s:is_table(line)
return
endif
let s:textwidth = &textwidth
let &textwidth = 0
endfunction
" TODO: move_column_left and move_column_right are good candidates to be refactored. " TODO: move_column_left and move_column_right are good candidates to be refactored.
function! vimwiki#tbl#move_column_left() abort function! vimwiki#tbl#move_column_left() abort

View File

@ -331,7 +331,6 @@ augroup vimwiki
" autowrap tables. " autowrap tables.
if vimwiki#vars#get_global('table_auto_fmt') if vimwiki#vars#get_global('table_auto_fmt')
exe 'autocmd InsertLeave '.pat.' call vimwiki#tbl#format(line("."), 2)' exe 'autocmd InsertLeave '.pat.' call vimwiki#tbl#format(line("."), 2)'
exe 'autocmd InsertEnter '.pat.' call vimwiki#tbl#reset_tw(line("."))'
endif endif
if vimwiki#vars#get_global('folding') =~? ':quick$' if vimwiki#vars#get_global('folding') =~? ':quick$'
" from http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_text " from http://vim.wikia.com/wiki/Keep_folds_closed_while_inserting_text