mirror of
https://github.com/dhruvasagar/vim-table-mode.git
synced 2025-11-08 11:03:47 -05:00
Fix column modifications if Unicode is involved
This commit is contained in:
@@ -46,13 +46,13 @@ endfunction
|
|||||||
|
|
||||||
function! tablemode#spreadsheet#MoveToFirstRow() "{{{2
|
function! tablemode#spreadsheet#MoveToFirstRow() "{{{2
|
||||||
if tablemode#table#IsRow('.')
|
if tablemode#table#IsRow('.')
|
||||||
call cursor(tablemode#spreadsheet#GetFirstRow('.'), col('.'))
|
call tablemode#utils#MoveToLine(tablemode#spreadsheet#GetFirstRow('.'))
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! tablemode#spreadsheet#MoveToFirstRowOrHeader() "{{{2
|
function! tablemode#spreadsheet#MoveToFirstRowOrHeader() "{{{2
|
||||||
if tablemode#table#IsRow('.')
|
if tablemode#table#IsRow('.')
|
||||||
call cursor(tablemode#spreadsheet#GetFirstRowOrHeader('.'), col('.'))
|
call tablemode#utils#MoveToLine(tablemode#spreadsheet#GetFirstRowOrHeader('.'))
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ endfunction
|
|||||||
|
|
||||||
function! tablemode#spreadsheet#MoveToLastRow() "{{{2
|
function! tablemode#spreadsheet#MoveToLastRow() "{{{2
|
||||||
if tablemode#table#IsRow('.')
|
if tablemode#table#IsRow('.')
|
||||||
call cursor(tablemode#spreadsheet#GetLastRow('.'), col('.'))
|
call tablemode#utils#MoveToLine(tablemode#spreadsheet#GetLastRow('.'))
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
@@ -51,3 +51,12 @@ endfunction
|
|||||||
function! tablemode#utils#get_buffer_or_global_option(table_option) "{{{2
|
function! tablemode#utils#get_buffer_or_global_option(table_option) "{{{2
|
||||||
return get(b:, a:table_option, get(g:, a:table_option))
|
return get(b:, a:table_option, get(g:, a:table_option))
|
||||||
endf
|
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
|
||||||
|
|||||||
@@ -193,4 +193,37 @@ describe 'spreadsheet'
|
|||||||
Expect getline('.') == '| 1 | 9 | | | a | z |'
|
Expect getline('.') == '| 1 | 9 | | | a | z |'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'Unicode table separators'
|
||||||
|
before
|
||||||
|
new
|
||||||
|
normal! ggdG
|
||||||
|
read t/fixtures/table/sample_realign_unicode_after.txt
|
||||||
|
call cursor(2, 19)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should not prevent the deletion of rows'
|
||||||
|
Expect tablemode#spreadsheet#RowCount('.') == 4
|
||||||
|
call tablemode#spreadsheet#DeleteRow()
|
||||||
|
Expect tablemode#spreadsheet#RowCount('.') == 3
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should not prevent the deletion of columns'
|
||||||
|
Expect tablemode#spreadsheet#ColumnCount('.') == 3
|
||||||
|
call tablemode#spreadsheet#DeleteColumn()
|
||||||
|
Expect tablemode#spreadsheet#ColumnCount('.') == 2
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should not prevent the insertion of columns before the cursor'
|
||||||
|
Expect tablemode#spreadsheet#ColumnCount('.') == 3
|
||||||
|
call tablemode#spreadsheet#InsertColumn(1)
|
||||||
|
Expect tablemode#spreadsheet#ColumnCount('.') == 4
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should not prevent the insertion of columns after the cursor'
|
||||||
|
Expect tablemode#spreadsheet#ColumnCount('.') == 3
|
||||||
|
call tablemode#spreadsheet#InsertColumn(1)
|
||||||
|
Expect tablemode#spreadsheet#ColumnCount('.') == 4
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user