Skip to content

Commit 79317c5

Browse files
authored
Merge pull request #72 from harshad1/do_not_use_normal_mode_to_insert
Do not use normal mode to replace / insert text
2 parents c9f915e + b94c2b9 commit 79317c5

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

plugin/bullets.vim

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -558,10 +558,7 @@ endfun
558558
fun! s:set_checkbox(lnum, marker)
559559
let l:initpos = getpos('.')
560560
let l:pos = s:find_checkbox_position(a:lnum)
561-
let l:checkbox_content = getline(a:lnum)[l:pos]
562-
" select inside checkbox
563-
call setpos('.', [0, a:lnum, l:pos])
564-
execute 'normal! ci[' . a:marker
561+
call s:replace_char_in_line(a:lnum, l:pos, a:marker)
565562
call setpos('.', l:initpos)
566563
endfun
567564

@@ -1244,6 +1241,13 @@ fun! s:sibling_checkbox_status(lnum)
12441241
return l:checkbox_markers[l:completion]
12451242
endfun
12461243

1244+
fun! s:replace_char_in_line(lnum, chari, item)
1245+
let l:curline = getline(a:lnum)
1246+
let l:before = strcharpart(l:curline, 0, a:chari)
1247+
let l:after = strcharpart(l:curline, a:chari + 1)
1248+
call setline(a:lnum, l:before . a:item . l:after)
1249+
endfun
1250+
12471251
" ------------------------------------------------------- }}}
12481252

12491253
" Restore previous external compatibility options --------- {{{

0 commit comments

Comments
 (0)