mirror of
https://github.com/dhruvasagar/vim-table-mode.git
synced 2025-11-10 12:03:48 -05:00
Fixed #3
This commit is contained in:
@@ -40,12 +40,6 @@ function! s:CountSeparator(line, separator) "{{{2
|
|||||||
endfunction
|
endfunction
|
||||||
" }}}2
|
" }}}2
|
||||||
|
|
||||||
function! s:ConvertDelimiterToSeparator(line) "{{{2
|
|
||||||
execute 'silent! ' . a:line . 's/^\s*\zs\ze.\|' . g:table_mode_delimiter .
|
|
||||||
\ '\|$/' . g:table_mode_separator . '/g'
|
|
||||||
endfunction
|
|
||||||
" }}}2
|
|
||||||
|
|
||||||
function! s:IsTableModeActive() "{{{2
|
function! s:IsTableModeActive() "{{{2
|
||||||
if g:table_mode_always_active | return 1 | endif
|
if g:table_mode_always_active | return 1 | endif
|
||||||
|
|
||||||
@@ -92,7 +86,7 @@ function! s:UpdateLineBorder(line) "{{{2
|
|||||||
endif
|
endif
|
||||||
else
|
else
|
||||||
call append(cline-1, repeat(g:table_mode_corner, curr_line_count))
|
call append(cline-1, repeat(g:table_mode_corner, curr_line_count))
|
||||||
let cline = a:line + 1
|
let cline = a:line + 1 " because of the append, the current line moved down
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if getline(cline+1) =~# hf
|
if getline(cline+1) =~# hf
|
||||||
@@ -129,9 +123,15 @@ function! s:Tableize() "{{{2
|
|||||||
endfunction
|
endfunction
|
||||||
" }}}2
|
" }}}2
|
||||||
|
|
||||||
|
function! s:ConvertDelimiterToSeparator(line) "{{{2
|
||||||
|
execute 'silent! ' . a:line . 's/^\s*\zs\ze.\|' . g:table_mode_delimiter .
|
||||||
|
\ '\|$/' . g:table_mode_separator . '/g'
|
||||||
|
endfunction
|
||||||
|
" }}}2
|
||||||
|
|
||||||
function! s:Tableizeline(line) "{{{2
|
function! s:Tableizeline(line) "{{{2
|
||||||
call s:ConvertDelimiterToSeparator(a:line)
|
call s:ConvertDelimiterToSeparator(a:line)
|
||||||
call s:UpdateLineBorder(a:line)
|
if g:table_mode_border | call s:UpdateLineBorder(a:line) | endif
|
||||||
execute 'Tabularize/[' . g:table_mode_separator . g:table_mode_corner . ']/' . g:table_mode_align
|
execute 'Tabularize/[' . g:table_mode_separator . g:table_mode_corner . ']/' . g:table_mode_align
|
||||||
endfunction
|
endfunction
|
||||||
" }}}2
|
" }}}2
|
||||||
@@ -161,17 +161,19 @@ endfunction
|
|||||||
" }}}2
|
" }}}2
|
||||||
|
|
||||||
function! tablemode#TableizeRange() range "{{{2
|
function! tablemode#TableizeRange() range "{{{2
|
||||||
|
let shift = 1
|
||||||
|
if g:table_mode_border | let shift = shift + 1 | endif
|
||||||
call s:Tableizeline(a:firstline)
|
call s:Tableizeline(a:firstline)
|
||||||
undojoin
|
undojoin
|
||||||
" The first one causes 2 extra lines for top & bottom border while the
|
" The first one causes 2 extra lines for top & bottom border while the
|
||||||
" following lines cause only 1 for the bottom border.
|
" following lines cause only 1 for the bottom border.
|
||||||
let lnum = a:firstline+3
|
let lnum = a:firstline + shift + (g:table_mode_border > 0)
|
||||||
while lnum <= (a:firstline + (a:lastline - a:firstline+1)*2)
|
while lnum < (a:firstline + (a:lastline - a:firstline + 1)*shift)
|
||||||
call s:Tableizeline(lnum)
|
call s:Tableizeline(lnum)
|
||||||
undojoin
|
undojoin
|
||||||
let lnum = lnum + 2
|
let lnum = lnum + shift
|
||||||
endwhile
|
endwhile
|
||||||
call s:FillTableBorder()
|
if g:table_mode_border | call s:FillTableBorder() | endif
|
||||||
endfunction
|
endfunction
|
||||||
" }}}2
|
" }}}2
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user