Skip to content

Commit b6b184b

Browse files
authored
Merge branch 'master' into caching_bullets_for_performance
2 parents 3598248 + 448ad2a commit b6b184b

2 files changed

Lines changed: 42 additions & 7 deletions

File tree

plugin/bullets.vim

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,9 @@ fun! s:match_checkbox_bullet_item(input_text)
288288
" match any symbols listed in g:bullets_checkbox_markers as well as the
289289
" default ' ', 'x', and 'X'
290290
let l:checkbox_bullet_regex =
291-
\ '\v(^(\s*)([-\*] \[(['
291+
\ '\v(^(\s*)([+-\*] \[(['
292292
\ . g:bullets_checkbox_markers
293-
\ . ' xX])?\])(\s+))(.*)'
293+
\ . ' xX])?\])(:?)(\s+))(.*)'
294294
let l:matches = matchlist(a:input_text, l:checkbox_bullet_regex)
295295

296296
if empty(l:matches)
@@ -301,16 +301,17 @@ fun! s:match_checkbox_bullet_item(input_text)
301301
let l:leading_space = l:matches[2]
302302
let l:bullet = l:matches[3]
303303
let l:checkbox_marker = l:matches[4]
304-
let l:trailing_space = l:matches[5]
305-
let l:text_after_bullet = l:matches[6]
304+
let l:trailing_char = l:matches[5]
305+
let l:trailing_space = l:matches[6]
306+
let l:text_after_bullet = l:matches[7]
306307

307308
return {
308309
\ 'bullet_type': 'chk',
309310
\ 'bullet_length': l:bullet_length,
310311
\ 'leading_space': l:leading_space,
311312
\ 'bullet': l:bullet,
312313
\ 'checkbox_marker': l:checkbox_marker,
313-
\ 'closure': '',
314+
\ 'closure': l:trailing_char,
314315
\ 'trailing_space': l:trailing_space,
315316
\ 'text_after_bullet': l:text_after_bullet
316317
\ }
@@ -631,14 +632,21 @@ command! InsertNewBullet call <SID>insert_new_bullet()
631632
" Helper for Colon Indent
632633
" returns 1 if current line ends in a colon, else 0
633634
fun! s:line_ends_in_colon(lnum)
634-
return getline(a:lnum)[strlen(getline(a:lnum))-1:] ==# ':'
635+
let l:line = getline(a:lnum)
636+
if exists("*strcharlen") && exists("*strgetchar")
637+
let l:last_char_nr = strgetchar(l:line, strcharlen(l:line)-1)
638+
return l:last_char_nr == 65306 || l:last_char_nr == 58
639+
else
640+
" Older versions of vim do not support strchar*
641+
return l:line[strlen(l:line)-1:] ==# ':'
642+
endif
635643
endfun
636644
" --------------------------------------------------------- }}}
637645

638646
" Checkboxes ---------------------------------------------- {{{
639647
fun! s:find_checkbox_position(lnum)
640648
let l:line_text = getline(a:lnum)
641-
return matchend(l:line_text, '\v\s*(\*|-) \[')
649+
return matchend(l:line_text, '\v\s*(\*|-|\+) \[')
642650
endfun
643651

644652
fun! s:select_checkbox(inner)

spec/nested_bullets_spec.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,33 @@
593593
\ti. this bullet is indented
594594
\tii. this bullet is also indented
595595
TEXT
596+
597+
write_file(filename, <<-TEXT)
598+
# Hello there
599+
a. this is the first bullet
600+
TEXT
601+
602+
vim.command 'let g:bullets_auto_indent_after_colon = 1'
603+
vim.edit filename
604+
vim.feedkeys '\<ESC>'
605+
vim.type 'GA'
606+
vim.feedkeys '\<cr>'
607+
vim.type 'this is the second bullet that ends with fullwidth colon:'
608+
vim.feedkeys '\<cr>'
609+
vim.type 'this bullet is indented'
610+
vim.feedkeys '\<cr>'
611+
vim.type 'this bullet is also indented'
612+
vim.write
613+
614+
file_contents = IO.read(filename)
615+
616+
expect(file_contents.strip).to eq normalize_string_indent(<<-TEXT)
617+
# Hello there
618+
a. this is the first bullet
619+
b. this is the second bullet that ends with fullwidth colon:
620+
\ti. this bullet is indented
621+
\tii. this bullet is also indented
622+
TEXT
596623
end
597624
end
598625
end

0 commit comments

Comments
 (0)