mirror of
https://github.com/dhruvasagar/vim-table-mode.git
synced 2025-11-08 11:03:47 -05:00
simplified the CountE function
cleanup for HTML comment tag checks
This commit is contained in:
@@ -50,13 +50,7 @@ function! s:Max(list) "{{{2
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:CountE(list) "{{{2
|
function! s:CountE(list) "{{{2
|
||||||
let result = 0
|
return len(filter(copy(a:list), {_,l -> empty(l)}))
|
||||||
for item in a:list
|
|
||||||
if empty(item)
|
|
||||||
let result += 1
|
|
||||||
endif
|
|
||||||
endfor
|
|
||||||
return result
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:CountNE(list) "{{{2
|
function! s:CountNE(list) "{{{2
|
||||||
|
|||||||
@@ -1,4 +1,8 @@
|
|||||||
" Private Functions {{{1
|
" Private Functions {{{1
|
||||||
|
function! s:IsHTMLComment(line) "{{{2
|
||||||
|
return getline(a:line) =~# '^\s*<!--'
|
||||||
|
endfunction
|
||||||
|
|
||||||
function! s:IsFormulaLine(line) "{{{2
|
function! s:IsFormulaLine(line) "{{{2
|
||||||
return getline(a:line) =~# 'tmf: '
|
return getline(a:line) =~# 'tmf: '
|
||||||
endfunction
|
endfunction
|
||||||
@@ -15,9 +19,7 @@ function! tablemode#spreadsheet#formula#Add(...) "{{{2
|
|||||||
let fr = '$' . row . ',' . colm . '=' . fr
|
let fr = '$' . row . ',' . colm . '=' . fr
|
||||||
let fline = tablemode#spreadsheet#GetLastRow('.') + 1
|
let fline = tablemode#spreadsheet#GetLastRow('.') + 1
|
||||||
if tablemode#table#IsBorder(fline) | let fline += 1 | endif
|
if tablemode#table#IsBorder(fline) | let fline += 1 | endif
|
||||||
if getline(fline) =~# '^\s*<!--' " ignore line with an HTML comment tag
|
if s:IsHTMLComment(fline) | let fline += 1 | endif
|
||||||
let fline += 1
|
|
||||||
endif
|
|
||||||
let cursor_pos = [line('.'), col('.')]
|
let cursor_pos = [line('.'), col('.')]
|
||||||
if getline(fline) =~# 'tmf: '
|
if getline(fline) =~# 'tmf: '
|
||||||
" Comment line correctly
|
" Comment line correctly
|
||||||
@@ -138,9 +140,7 @@ function! tablemode#spreadsheet#formula#EvaluateFormulaLine() abort "{{{2
|
|||||||
if tablemode#table#IsRow('.') " We're inside the table
|
if tablemode#table#IsRow('.') " We're inside the table
|
||||||
let line = tablemode#spreadsheet#GetLastRow('.')
|
let line = tablemode#spreadsheet#GetLastRow('.')
|
||||||
let fline = line + 1
|
let fline = line + 1
|
||||||
if getline(fline) =~# '^\s*<!--' " ignore line with an HTML comment tag
|
if s:IsHTMLComment(fline) | let fline += 1 | endif
|
||||||
let fline += 1
|
|
||||||
endif
|
|
||||||
if tablemode#table#IsBorder(fline) | let fline += 1 | endif
|
if tablemode#table#IsBorder(fline) | let fline += 1 | endif
|
||||||
while s:IsFormulaLine(fline)
|
while s:IsFormulaLine(fline)
|
||||||
let exprs += split(matchstr(getline(fline), matchexpr), ';')
|
let exprs += split(matchstr(getline(fline), matchexpr), ';')
|
||||||
@@ -150,9 +150,7 @@ function! tablemode#spreadsheet#formula#EvaluateFormulaLine() abort "{{{2
|
|||||||
let fline = line('.')
|
let fline = line('.')
|
||||||
let line = line('.') - 1
|
let line = line('.') - 1
|
||||||
while s:IsFormulaLine(line) | let fline = line | let line -= 1 | endwhile
|
while s:IsFormulaLine(line) | let fline = line | let line -= 1 | endwhile
|
||||||
if getline(fline) =~# '^\s*<!--' " ignore line with an HTML comment tag
|
if s:IsHTMLComment(line) | let line -= 1 | endif
|
||||||
let line -= 1
|
|
||||||
endif
|
|
||||||
if tablemode#table#IsBorder(line) | let line -= 1 | endif
|
if tablemode#table#IsBorder(line) | let line -= 1 | endif
|
||||||
if tablemode#table#IsRow(line)
|
if tablemode#table#IsRow(line)
|
||||||
" let exprs = split(matchstr(getline('.'), matchexpr), ';')
|
" let exprs = split(matchstr(getline('.'), matchexpr), ';')
|
||||||
|
|||||||
Reference in New Issue
Block a user