Minor Fixes

- Updated s:EndExpr() to include \s\+ within optional escaped comment so
  that the space is also matched.
- Fixed Formula addition in case of double comment (start and end) are
  required, eg) in c/c++.
- Parsing expr row/column numbers from string correctly.
This commit is contained in:
Dhruva Sagar
2013-05-20 16:38:31 +05:30
parent 8931891845
commit 3cea0bbaba

View File

@@ -129,7 +129,7 @@ endfunction
function! s:EndExpr() "{{{2 function! s:EndExpr() "{{{2
let cend = s:GetCommentEnd() let cend = s:GetCommentEnd()
if s:Strlen(cend) > 0 if s:Strlen(cend) > 0
return '\s*\(' . cend . '\)\?\s*$' return '\s*\(\s\+' . cend . '\)\?\s*$'
else else
return '\s*$' return '\s*$'
endif endif
@@ -910,7 +910,12 @@ function! tablemode#AddFormula() "{{{2
let fline = tablemode#GetLastRow('.') + s:RowGap() let fline = tablemode#GetLastRow('.') + s:RowGap()
let cursor_pos = [line('.'), col('.')] let cursor_pos = [line('.'), col('.')]
if getline(fline) =~# 'tmf: ' if getline(fline) =~# 'tmf: '
call setline(fline, getline(fline) . ';' . fr) " Comment line correctly
let line_val = getline(fline)
let line_expr = line_val[match(line_val, s:StartCommentExpr()):match(line_val, s:EndCommentExpr())]
let sce = matchstr(line_val, s:StartCommentExpr() . '\zs')
let ece = matchstr(line_val, s:EndCommentExpr())
call setline(fline, sce . line_expr . '; ' . fr . ece)
else else
let cstring = &commentstring let cstring = &commentstring
let [cmss, cmse] = ['', ''] let [cmss, cmse] = ['', '']
@@ -933,12 +938,12 @@ endfunction
function! tablemode#EvaluateExpr(expr, line) abort "{{{2 function! tablemode#EvaluateExpr(expr, line) abort "{{{2
let line = s:Line(a:line) let line = s:Line(a:line)
let [target, expr] = split(a:expr, '=') let [target, expr] = map(split(a:expr, '='), 's:Strip(v:val)')
let cell = substitute(target, '\$', '', '') let cell = substitute(target, '\$', '', '')
if cell =~# ',' if cell =~# ','
let [row, colm] = split(cell, ',') let [row, colm] = map(split(cell, ','), 'str2nr(v:val)')
else else
let [row, colm] = [0, cell] let [row, colm] = [0, str2nr(cell)]
endif endif
if expr =~# 'Sum(.*)' if expr =~# 'Sum(.*)'