Skip to content

Commit 85d31e2

Browse files
committed
Try adding newline after bracket instead of using backslash
1 parent 99d3c50 commit 85d31e2

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

indent/python.vim

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -563,13 +563,13 @@ function! GetPythonPEPFormat(lnum, count)
563563
" 2. Breaking inside brackets is preferred (no backslash needed)
564564
" 3. Breking outside a string is preferred (new breakpoint)
565565
" 4. Possible future: breaking at space is preferred
566-
if l:breakpoint[0] != 0 && s:isBetweenBrackets(l:breakpointview)
566+
if l:breakpoint[1] > indent(a:lnum) && s:isBetweenBrackets(l:breakpointview)
567567
"echom 'between brackets'
568568
call winrestview(l:breakpointview)
569569
call feedkeys("r\<CR>", 'n')
570570
else
571571
"echom 'zooooi'
572-
if l:better_orig_breakpoint[0] != 0
572+
if l:better_orig_breakpoint[1] > indent(a:lnum)
573573
\ && s:isBetweenBrackets(l:better_orig_breakpointview)
574574
" echom 'doing the quotes'
575575
call winrestview(l:better_orig_breakpointview)
@@ -596,8 +596,10 @@ function! GetPythonPEPFormat(lnum, count)
596596
call winrestview(l:breakpointview)
597597

598598
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)
599+
if l:next_char ==# '{' || l:next_char ==# '(' || l:next_char ==# '['
600+
"Add a newline after the bracket
601+
call feedkeys("la\<CR>\<esc>", 'n')
602+
elseif !s:isBetweenBrackets(l:breakpointview)
601603
"Add a bracket when this is not present yet
602604
call winrestview(l:breakpointview)
603605
call feedkeys("a(\<esc>", 'n')

0 commit comments

Comments
 (0)