Skip to content

Commit 2246641

Browse files
committed
closes tomtom#233 and tomtom#234
* always substitute comment markers in entire block comment * indentation of block comments respects tabstop and expandtab settings
1 parent 622cc05 commit 2246641

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

autoload/tcomment.vim

+6-3
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,6 @@ endf
817817

818818
function! s:CommentBlock(beg, end, cbeg, cend, comment_mode, comment_do, checkRx, cdef) abort
819819
Tlibtrace 'tcomment', a:beg, a:end, a:cbeg, a:cend, a:comment_do, a:checkRx, a:cdef
820-
let indentStr = repeat(' ', a:cbeg)
821820
let t = @t
822821
let sel_save = &selection
823822
set selection=exclusive
@@ -874,9 +873,13 @@ function! s:CommentBlock(beg, end, cbeg, cend, comment_mode, comment_do, checkRx
874873
endif
875874
endif
876875
else
876+
let indentStr = repeat(' ', a:cbeg)
877+
if &expandtab == 0
878+
let indentStr = substitute(indentStr, repeat(' ', &tabstop), '\t', 'g')
879+
endif
877880
let cs = indentStr . substitute(cs, '%\@<!%s', '%s'. indentStr, '')
878881
Tlibtrace 'tcomment', cs, ms
879-
if !empty(ms)
882+
" if !empty(ms)
880883
let lines = []
881884
let lnum = 0
882885
let indentlen = a:cbeg
@@ -905,7 +908,7 @@ function! s:CommentBlock(beg, end, cbeg, cend, comment_mode, comment_do, checkRx
905908
endif
906909
let @t = join(lines, "\n")
907910
Tlibtrace 'tcomment', 3, @t
908-
endif
911+
" endif
909912
let @t = tcomment#format#Printf1(cs, "\n". @t ."\n")
910913
Tlibtrace 'tcomment', 4, cs, @t, a:comment_mode
911914
if a:comment_mode =~# '#'

0 commit comments

Comments
 (0)