Fixed issue with table formula addition when there exists one already
and the comment string is singular, i.e. no end delimiter.
This commit is contained in:
Dhruva Sagar
2016-04-09 12:55:29 +05:30
parent 01289c0752
commit 4cf1f53430

View File

@@ -16,7 +16,10 @@ function! tablemode#spreadsheet#formula#Add(...) "{{{2
if getline(fline) =~# 'tmf: ' if getline(fline) =~# 'tmf: '
" Comment line correctly " Comment line correctly
let line_val = getline(fline) let line_val = getline(fline)
let line_expr = line_val[match(line_val, tablemode#table#StartCommentExpr()):match(line_val, tablemode#table#EndCommentExpr())] let start_pos = match(line_val, tablemode#table#StartCommentExpr())
let end_pos = match(line_val, tablemode#table#EndCommentExpr())
if empty(end_pos) | let end_pos = len(line_val) | endif
let line_expr = strpart(line_val, start_pos, end_pos)
let sce = matchstr(line_val, tablemode#table#StartCommentExpr() . '\zs') let sce = matchstr(line_val, tablemode#table#StartCommentExpr() . '\zs')
let ece = matchstr(line_val, tablemode#table#EndCommentExpr()) let ece = matchstr(line_val, tablemode#table#EndCommentExpr())
call setline(fline, sce . line_expr . '; ' . fr . ece) call setline(fline, sce . line_expr . '; ' . fr . ece)