mirror of
https://github.com/dhruvasagar/vim-table-mode.git
synced 2025-11-08 11:03:47 -05:00
Improved fix for #20
Instead of relying on a /g or /gg flag based on gdefault, I temporarily disable gdefault and set it back to the old value aftwards.
This commit is contained in:
@@ -51,13 +51,13 @@ function! s:SetActive(bool) "{{{2
|
||||
endfunction
|
||||
|
||||
function! s:ConvertDelimiterToSeparator(line, ...) "{{{2
|
||||
let gflag = 'g'
|
||||
if &gdefault | let gflag = 'gg' | endif
|
||||
let old_gdefault = &gdefault
|
||||
set nogdefault
|
||||
|
||||
let delim = g:table_mode_delimiter
|
||||
if a:0 | let delim = a:1 | endif
|
||||
if delim ==# ','
|
||||
silent! execute a:line . 's/' . "[\'\"][^\'\"]*\\zs,\\ze[^\'\"]*[\'\"]/__COMMA__/" . gflag
|
||||
silent! execute a:line . 's/' . "[\'\"][^\'\"]*\\zs,\\ze[^\'\"]*[\'\"]/__COMMA__/g"
|
||||
endif
|
||||
|
||||
let [cstart, cend] = [tablemode#table#GetCommentStart(), tablemode#table#GetCommentEnd()]
|
||||
@@ -67,11 +67,13 @@ function! s:ConvertDelimiterToSeparator(line, ...) "{{{2
|
||||
|
||||
silent! execute a:line . 's/' . tablemode#table#StartExpr() . '\zs\ze' . match_char_start .
|
||||
\ '\|' . delim . '\|' . match_char_end . '\zs\ze' . tablemode#table#EndExpr() . '/' .
|
||||
\ g:table_mode_separator . '/' . gflag
|
||||
\ g:table_mode_separator . '/g'
|
||||
|
||||
if delim ==# ','
|
||||
silent! execute a:line . 's/' . "[\'\"][^\'\"]*\\zs__COMMA__\\ze[^\'\"]*[\'\"]/,/" . gflag
|
||||
silent! execute a:line . 's/' . "[\'\"][^\'\"]*\\zs__COMMA__\\ze[^\'\"]*[\'\"]/,/g"
|
||||
endif
|
||||
|
||||
let &gdefault=old_gdefault
|
||||
endfunction
|
||||
|
||||
function! s:Tableizeline(line, ...) "{{{2
|
||||
|
||||
Reference in New Issue
Block a user