Fix column modifications if Unicode is involved

This commit is contained in:
ibbem
2020-04-03 20:23:23 +02:00
parent 0b58003b68
commit 67129cd1e0
3 changed files with 45 additions and 3 deletions

View File

@@ -46,13 +46,13 @@ endfunction
function! tablemode#spreadsheet#MoveToFirstRow() "{{{2
if tablemode#table#IsRow('.')
call cursor(tablemode#spreadsheet#GetFirstRow('.'), col('.'))
call tablemode#utils#MoveToLine(tablemode#spreadsheet#GetFirstRow('.'))
endif
endfunction
function! tablemode#spreadsheet#MoveToFirstRowOrHeader() "{{{2
if tablemode#table#IsRow('.')
call cursor(tablemode#spreadsheet#GetFirstRowOrHeader('.'), col('.'))
call tablemode#utils#MoveToLine(tablemode#spreadsheet#GetFirstRowOrHeader('.'))
endif
endfunction
@@ -71,7 +71,7 @@ endfunction
function! tablemode#spreadsheet#MoveToLastRow() "{{{2
if tablemode#table#IsRow('.')
call cursor(tablemode#spreadsheet#GetLastRow('.'), col('.'))
call tablemode#utils#MoveToLine(tablemode#spreadsheet#GetLastRow('.'))
endif
endfunction

View File

@@ -51,3 +51,12 @@ endfunction
function! tablemode#utils#get_buffer_or_global_option(table_option) "{{{2
return get(b:, a:table_option, get(g:, a:table_option))
endf
function tablemode#utils#MoveToLine(line) "{{{2
let offset = tablemode#utils#line(a:line) - line('.')
if offset > 0
execute "normal! ".offset."j"
elseif offset < 0
execute "normal! ".(-offset)."k"
endif
endfunction