@@ -440,13 +440,15 @@ let &cpo = s:cpo_save
440
440
unlet s: cpo_save
441
441
442
442
function ! Fixedgq (lnum, count )
443
+ let l: tw = &tw ? &tw : 72 ;
444
+
443
445
let l: count = a: count
444
446
445
447
if mode () == ' i' " gq was not pressed, but tw was set
446
448
return 1
447
449
endif
448
450
449
- if len (getline (a: lnum )) < 80 && l: count == 1 " No need for gq
451
+ if len (getline (a: lnum )) < l: tw && l: count == 1 " No need for gq
450
452
return 1
451
453
endif
452
454
@@ -460,9 +462,9 @@ function! Fixedgq(lnum, count)
460
462
461
463
let l: winview = winsaveview ()
462
464
463
- call cursor (a: lnum , 81 )
465
+ call cursor (a: lnum , l: tw + 1 )
464
466
let orig_breakpoint = searchpairpos (' ' , ' ' , ' \.' , ' bcW' , ' ' , a: lnum )
465
- call cursor (a: lnum , 81 )
467
+ call cursor (a: lnum , l: tw + 1 )
466
468
let breakpoint = searchpairpos (' ' , ' ' , ' \.' , ' bcW' , s: skip_expr , a: lnum )
467
469
468
470
" No need for special treatment, normal gq handles edgecases better
@@ -473,7 +475,7 @@ function! Fixedgq(lnum, count)
473
475
474
476
" Try breaking after string
475
477
if breakpoint[1 ] <= indent (a: lnum )
476
- call cursor (a: lnum , 81 )
478
+ call cursor (a: lnum , l: tw + 1 )
477
479
let breakpoint = searchpairpos (' \.' , ' ' , ' ' , ' cW' , s: skip_expr , a: lnum )
478
480
endif
479
481
0 commit comments