Skip to content

Commit e9fe46a

Browse files
committed
Wrapper function; don't include line number
1 parent 76429d5 commit e9fe46a

1 file changed

Lines changed: 19 additions & 15 deletions

File tree

plugin/bullets.vim

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -144,36 +144,40 @@ fun! s:disable_bullet_cache()
144144
endif
145145
endfun
146146

147-
148147
fun! s:parse_bullet(line_num, line_text)
148+
let l:kinds = s:parse_bullet_text(a:line_text)
149+
150+
for l:data in l:kinds
151+
let l:data.starting_at_line_num = a:line_num
152+
endfor
153+
154+
return l:kinds
155+
endfun
156+
157+
fun! s:parse_bullet_text(line_text)
149158

150159
if s:bullet_cache isnot v:null
151-
let l:key = a:line_text . a:line_num
152-
let l:cached = get(s:bullet_cache, l:key, v:null)
160+
let l:cached = get(s:bullet_cache, l:line_text, v:null)
153161
if l:cached isnot v:null
154-
return l:cached
162+
" Return a copy so as not to break the referene
163+
return copy(l:cached)
155164
endif
156165
endif
157166

158167
let l:bullet = s:match_bullet_list_item(a:line_text)
159168
" Must be a bullet to be a checkbox
160-
let l:check = !empty(l:bullet) ? s:match_checkbox_bullet_item(a:line_text) : {}
169+
let l:check = !empty(l:bullet) ? s:match_checkbox_bullet_item(a:line_text) : v:null
161170
" Cannot be numeric if a bullet
162-
let l:num = empty(l:bullet) ? s:match_numeric_list_item(a:line_text) : {}
171+
let l:num = empty(l:bullet) ? s:match_numeric_list_item(a:line_text) : v:null
163172
" Cannot be alphabetic if numeric or a bullet
164-
let l:alpha = empty(l:bullet) && empty(l:num) ? s:match_alphabetical_list_item(a:line_text) : {}
173+
let l:alpha = empty(l:bullet) && empty(l:num) ? s:match_alphabetical_list_item(a:line_text) : v:null
165174
" Cannot be roman if numeric or a bullet
166-
let l:roman = empty(l:bullet) && empty(l:num) ? s:match_roman_list_item(a:line_text) : {}
167-
168-
let l:kinds = s:filter([l:bullet, l:check, l:num, l:alpha, l:roman], '!empty(v:val)')
175+
let l:roman = empty(l:bullet) && empty(l:num) ? s:match_roman_list_item(a:line_text) : v:null
169176

170-
for l:data in l:kinds
171-
let l:data.starting_at_line_num = a:line_num
172-
endfor
177+
let l:kinds = s:filter([l:bullet, l:check, l:num, l:alpha, l:roman], 'v:val isnot v:null')
173178

174179
if s:bullet_cache isnot v:null
175-
let l:key = a:line_text . a:line_num
176-
let s:bullet_cache[l:key] = l:kinds
180+
let s:bullet_cache[a:line_text] = l:kinds
177181
endif
178182

179183
return l:kinds

0 commit comments

Comments
 (0)