Skip to content

Commit 99d3c50

Browse files
committed
Add a bracket intsead of backslash + newline when it can help
1 parent d77a6cc commit 99d3c50

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

indent/python.vim

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,18 @@ function! GetPythonPEPFormat(lnum, count)
594594
endif
595595
elseif l:breakpoint[1] > indent(a:lnum)
596596
call winrestview(l:breakpointview)
597-
call feedkeys("a\\\<CR>\<esc>", 'n')
597+
598+
let l:next_char = getline(a:lnum)[l:breakpoint[1]]
599+
if l:next_char !=# '{' && l:next_char !=# '(' && l:next_char !=# '['
600+
\ && !s:isBetweenBrackets(l:breakpointview)
601+
"Add a bracket when this is not present yet
602+
call winrestview(l:breakpointview)
603+
call feedkeys("a(\<esc>", 'n')
604+
else
605+
"Otherwise fall back to a backslash
606+
call winrestview(l:breakpointview)
607+
call feedkeys("a\\\<CR>\<esc>", 'n')
608+
endif
598609
else
599610
call cursor(a:lnum, l:tw + 1)
600611
"Search for a space that is not trailing whitespace

0 commit comments

Comments
 (0)