Skip to content

Commit 0f01f09

Browse files
committed
insert_empty_lines_before_comment: adjust indent
1 parent 2bb8d40 commit 0f01f09

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

py/pycompiler.vim

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,16 @@ function s:PythonCompiler.insert_empty_lines_before_comment(count)
330330
let comment_start = 0
331331
let len_lines = len(self.lines)
332332
if len_lines
333-
while get(self.lines, comment_start - 1, '') =~# '^\s*#'
333+
while 1
334+
let line = get(self.lines, comment_start - 1, '')
335+
if line !~# '^\s*#'
336+
break
337+
endif
334338
let comment_start -= 1
339+
" Adjust indentation to current level.
340+
let self.lines[comment_start] = substitute(line, '^\s\+', self.indent[0], '')
335341
endwhile
342+
336343
if comment_start != 0
337344
let comment_start = len_lines + comment_start
338345
endif

0 commit comments

Comments
 (0)