mirror of
https://github.com/dhruvasagar/vim-table-mode.git
synced 2025-11-09 11:33:47 -05:00
Fixed tablemode#TableMotion
This commit is contained in:
@@ -789,51 +789,54 @@ function! tablemode#ColumnNr(pos) "{{{2
|
|||||||
return s:Strlen(substitute(getline(pos[0])[(row_start):pos[1]-2], '[^' . g:table_mode_separator . ']', '', 'g'))
|
return s:Strlen(substitute(getline(pos[0])[(row_start):pos[1]-2], '[^' . g:table_mode_separator . ']', '', 'g'))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! tablemode#TableMotion(direction) "{{{2
|
function! tablemode#TableMotion(direction, ...) "{{{2
|
||||||
|
let l:count = a:0 ? a:1 : v:count1
|
||||||
if tablemode#IsATableRow('.')
|
if tablemode#IsATableRow('.')
|
||||||
if a:direction ==# 'l'
|
for ii in range(l:count)
|
||||||
if s:IsLastCell()
|
if a:direction ==# 'l'
|
||||||
if !tablemode#IsATableRow(line('.') + s:RowGap()) || (tablemode#IsATableHeader(line('.') + s:RowGap()) && tablemode#IsATableRow(line('.') + 2 * s:RowGap()))
|
if s:IsLastCell()
|
||||||
return
|
if !tablemode#IsATableRow(line('.') + s:RowGap()) || (tablemode#IsATableHeader(line('.') + s:RowGap()) && !tablemode#IsATableRow(line('.') + 2 * s:RowGap()))
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
call tablemode#TableMotion('j', 1)
|
||||||
|
normal! 0
|
||||||
endif
|
endif
|
||||||
call tablemode#TableMotion('j')
|
|
||||||
normal! 0
|
|
||||||
endif
|
|
||||||
|
|
||||||
" If line starts with g:table_mode_separator
|
" If line starts with g:table_mode_separator
|
||||||
if getline('.')[col('.')-1] ==# g:table_mode_separator
|
if getline('.')[col('.')-1] ==# g:table_mode_separator
|
||||||
normal! 2l
|
normal! 2l
|
||||||
else
|
else
|
||||||
execute 'normal! f' . g:table_mode_separator . '2l'
|
execute 'normal! f' . g:table_mode_separator . '2l'
|
||||||
endif
|
endif
|
||||||
elseif a:direction ==# 'h'
|
elseif a:direction ==# 'h'
|
||||||
if s:IsFirstCell()
|
if s:IsFirstCell()
|
||||||
if !tablemode#IsATableRow(line('.') - s:RowGap()) || (tablemode#IsATableHeader(line('.') - s:RowGap()) && tablemode#IsATableRow(line('.') - 2 * s:RowGap()))
|
if !tablemode#IsATableRow(line('.') - s:RowGap()) || (tablemode#IsATableHeader(line('.') - s:RowGap()) && !tablemode#IsATableRow(line('.') - 2 * s:RowGap()))
|
||||||
return
|
return
|
||||||
|
endif
|
||||||
|
call tablemode#TableMotion('k', 1)
|
||||||
|
normal! $
|
||||||
endif
|
endif
|
||||||
call tablemode#TableMotion('k')
|
|
||||||
normal! $
|
|
||||||
endif
|
|
||||||
|
|
||||||
" If line ends with g:table_mode_separator
|
" If line ends with g:table_mode_separator
|
||||||
if getline('.')[col('.')-1] ==# g:table_mode_separator
|
if getline('.')[col('.')-1] ==# g:table_mode_separator
|
||||||
execute 'normal! F' . g:table_mode_separator . '2l'
|
execute 'normal! F' . g:table_mode_separator . '2l'
|
||||||
else
|
else
|
||||||
execute 'normal! 2F' . g:table_mode_separator . '2l'
|
execute 'normal! 2F' . g:table_mode_separator . '2l'
|
||||||
|
endif
|
||||||
|
elseif a:direction ==# 'j'
|
||||||
|
if tablemode#IsATableRow(line('.') + s:RowGap())
|
||||||
|
execute 'normal! ' . s:RowGap() . 'j'
|
||||||
|
elseif tablemode#IsATableHeader(line('.') + s:RowGap()) && tablemode#IsATableRow(line('.') + 2 * s:RowGap())
|
||||||
|
execute 'normal! ' . (s:RowGap() + 1) . 'j'
|
||||||
|
endif
|
||||||
|
elseif a:direction ==# 'k'
|
||||||
|
if tablemode#IsATableRow(line('.') - s:RowGap())
|
||||||
|
execute 'normal! ' . s:RowGap() . 'k'
|
||||||
|
elseif tablemode#IsATableHeader(line('.') - s:RowGap()) && tablemode#IsATableRow(line('.') - 2 * s:RowGap())
|
||||||
|
execute 'normal! ' . (s:RowGap() + 1) . 'k'
|
||||||
|
endif
|
||||||
endif
|
endif
|
||||||
elseif a:direction ==# 'j'
|
endfor
|
||||||
if tablemode#IsATableRow(line('.') + s:RowGap())
|
|
||||||
execute 'normal! ' . s:RowGap() . 'j'
|
|
||||||
elseif tablemode#IsATableHeader(line('.') + s:RowGap()) && tablemode#IsATableRow(line('.') + 2 * s:RowGap())
|
|
||||||
execute 'normal! ' . (s:RowGap() + 1) . 'j'
|
|
||||||
endif
|
|
||||||
elseif a:direction ==# 'k'
|
|
||||||
if tablemode#IsATableRow(line('.') - s:RowGap())
|
|
||||||
execute 'normal! ' . s:RowGap() . 'k'
|
|
||||||
elseif tablemode#IsATableHeader(line('.') - s:RowGap()) && tablemode#IsATableRow(line('.') - 2 * s:RowGap())
|
|
||||||
execute 'normal! ' . (s:RowGap() + 1) . 'k'
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user