@@ -512,14 +512,17 @@ function! GetPythonPEPFormat(lnum, count)
512
512
endwhile
513
513
endif
514
514
515
- call cursor (a: lnum , l: tw + 1 )
515
+ let l: twplus1 = s: VirtcolToCol (a: lnum , l: tw + 1 )
516
+ let l: twminus1 = s: VirtcolToCol (a: lnum , l: tw - 1 )
517
+
518
+ call cursor (a: lnum , l: twplus1 )
516
519
let l: orig_breakpoint = searchpos (' ' , ' bcW' , a: lnum )
517
520
let l: orig_breakpointview = winsaveview ()
518
521
" If breaking inside string extra space is needed for the space and quote
519
- call cursor (a: lnum , l: tw - 1 )
522
+ call cursor (a: lnum , l: twminus1 )
520
523
let l: better_orig_breakpoint = searchpos (' ' , ' bcW' , a: lnum )
521
524
let l: better_orig_breakpointview = winsaveview ()
522
- call cursor (a: lnum , l: tw + 1 )
525
+ call cursor (a: lnum , l: twplus1 )
523
526
let l: breakpoint = s: SearchPosWithSkip (' ' , ' bcW' , s: skip_string , a: lnum )
524
527
let l: breakpointview = winsaveview ()
525
528
@@ -609,7 +612,7 @@ function! GetPythonPEPFormat(lnum, count)
609
612
call feedkeys (" a\\ \<CR>\<esc> " , ' n' )
610
613
endif
611
614
else
612
- call cursor (a: lnum , l: tw + 1 )
615
+ call cursor (a: lnum , l: twplus1 )
613
616
" Search for a space that is not trailing whitespace
614
617
let l: afterbreakpoint = s: SearchPosWithSkip (' [^ ]' , ' cW' , s: skip_string , a: lnum )
615
618
@@ -639,3 +642,14 @@ function s:isBetweenPair(left, right, winview, skip)
639
642
let l: bracket = searchpairpos (a: left , ' ' , a: right , ' bW' , a: skip )
640
643
return l: bracket [0 ] != 0
641
644
endfunction
645
+
646
+ function s: VirtcolToCol (lnum, cnum)
647
+ let l: last = virtcol ([a: lnum , ' $' ])
648
+ let l: cnum = a: cnum
649
+ let l: vcol = virtcol ([a: lnum , l: cnum ])
650
+ while l: vcol < a: cnum && l: vcol < l: last
651
+ let l: cnum += 1
652
+ let l: vcol = virtcol ([a: lnum , l: cnum ])
653
+ endwhile
654
+ return l: cnum + 1
655
+ endfunction
0 commit comments