Skip to content

Commit 57d9b86

Browse files
committed
Merge branch 'master' into caching_bullets_for_performance
2 parents 0664f78 + 50ea5b7 commit 57d9b86

2 files changed

Lines changed: 51 additions & 2 deletions

File tree

plugin/bullets.vim

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ if !exists('g:bullets_max_alpha_characters')
6262
let g:bullets_max_alpha_characters = 2
6363
end
6464

65+
if !exists('g:bullets_enable_roman_list')
66+
let g:bullets_enable_roman_list = 1
67+
end
68+
6569
" calculate the decimal equivalent to the last alphabetical list item
6670
let s:power = g:bullets_max_alpha_characters
6771
let s:abc_max = -1
@@ -211,6 +215,10 @@ endfun
211215

212216

213217
fun! s:match_roman_list_item(input_text)
218+
if g:bullets_enable_roman_list == 0
219+
return {}
220+
endif
221+
214222
let l:rom_bullet_regex = join([
215223
\ '\v\C',
216224
\ '^(',
@@ -632,8 +640,14 @@ command! InsertNewBullet call <SID>insert_new_bullet()
632640
" Helper for Colon Indent
633641
" returns 1 if current line ends in a colon, else 0
634642
fun! s:line_ends_in_colon(lnum)
635-
let l:last_char_nr = strgetchar(getline(a:lnum), strcharlen(getline(a:lnum))-1)
636-
return l:last_char_nr == 65306 || l:last_char_nr == 58
643+
let l:line = getline(a:lnum)
644+
if exists("*strcharlen") && exists("*strgetchar")
645+
let l:last_char_nr = strgetchar(l:line, strcharlen(l:line)-1)
646+
return l:last_char_nr == 65306 || l:last_char_nr == 58
647+
else
648+
" Older versions of vim do not support strchar*
649+
return l:line[strlen(l:line)-1:] ==# ':'
650+
endif
637651
endfun
638652
" --------------------------------------------------------- }}}
639653

spec/bullets_spec.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,41 @@
293293
-
294294
TEXT
295295
end
296+
297+
it 'toggles roman numeral bullets with g:bullets_enable_roman_list' do
298+
filename = "#{SecureRandom.hex(6)}.txt"
299+
write_file(filename, <<-TEXT)
300+
# Hello there
301+
i. this is the first bullet
302+
TEXT
303+
304+
# Disable alpha lists to isolate test to roman numerals
305+
vim.command 'let g:bullets_max_alpha_characters = 0'
306+
vim.command 'let g:bullets_enable_roman_list = 1'
307+
vim.edit filename
308+
vim.type 'GA'
309+
vim.feedkeys '\<cr>'
310+
vim.type 'second bullet'
311+
vim.feedkeys '\<cr>'
312+
vim.type 'third bullet'
313+
vim.command 'let g:bullets_enable_roman_list = 0'
314+
vim.feedkeys '\<cr>'
315+
vim.type 'fourth bullet'
316+
vim.feedkeys '\<cr>'
317+
vim.type 'fifth bullet'
318+
vim.write
319+
320+
file_contents = IO.read(filename)
321+
322+
expect(file_contents).to eq normalize_string_indent(<<-TEXT)
323+
# Hello there
324+
i. this is the first bullet
325+
ii. second bullet
326+
iii. third bullet
327+
fourth bullet
328+
fifth bullet\n
329+
TEXT
330+
end
296331
end
297332
end
298333
end

0 commit comments

Comments
 (0)