Disabling InsertLeave autocmd for realign since it is getting triggered
multiple times during realignment and causes issues while creation of
tables
This commit is contained in:
Dhruva Sagar
2018-03-22 09:40:50 +05:30
parent d0a6405189
commit e646bee5c4

View File

@@ -99,7 +99,7 @@ function! s:ToggleAutoAlign() "{{{2
au!
autocmd CursorHold <buffer> nested silent! if &modified | call tablemode#table#Realign('.') | endif
autocmd InsertLeave <buffer> nested silent! if &modified | call tablemode#table#Realign('.') | endif
" autocmd InsertLeave <buffer> nested silent! if &modified | call tablemode#table#Realign('.') | endif
augroup END
else
autocmd! TableModeAutoAlign
@@ -169,15 +169,17 @@ function! tablemode#IsActive() "{{{2
endfunction
function! tablemode#TableizeInsertMode() "{{{2
if tablemode#IsActive() && getline('.') =~# (tablemode#table#StartExpr() . g:table_mode_separator . g:table_mode_separator)
call tablemode#table#AddBorder('.')
normal! A
elseif tablemode#IsActive() && getline('.') =~# (tablemode#table#StartExpr() . g:table_mode_separator)
let column = tablemode#utils#strlen(substitute(getline('.')[0:col('.')], '[^' . g:table_mode_separator . ']', '', 'g'))
let position = tablemode#utils#strlen(matchstr(getline('.')[0:col('.')], '.*' . g:table_mode_separator . '\s*\zs.*'))
call tablemode#table#Realign('.')
normal! 0
call search(repeat('[^' . g:table_mode_separator . ']*' . g:table_mode_separator, column) . '\s\{-\}' . repeat('.', position), 'ce', line('.'))
if tablemode#IsActive()
if getline('.') =~# (tablemode#table#StartExpr() . g:table_mode_separator . g:table_mode_separator)
call tablemode#table#AddBorder('.')
normal! A
elseif getline('.') =~# (tablemode#table#StartExpr() . g:table_mode_separator)
let column = tablemode#utils#strlen(substitute(getline('.')[0:col('.')], '[^' . g:table_mode_separator . ']', '', 'g'))
let position = tablemode#utils#strlen(matchstr(getline('.')[0:col('.')], '.*' . g:table_mode_separator . '\s*\zs.*'))
call tablemode#table#Realign('.')
normal! 0
call search(repeat('[^' . g:table_mode_separator . ']*' . g:table_mode_separator, column) . '\s\{-\}' . repeat('.', position), 'ce', line('.'))
endif
endif
endfunction