Skip to content

Commit 18106a3

Browse files
committed
Use &tw instead of hard-coded 80 for formatting
1 parent 125f931 commit 18106a3

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

indent/javascript.vim

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -440,13 +440,15 @@ let &cpo = s:cpo_save
440440
unlet s:cpo_save
441441

442442
function! Fixedgq(lnum, count)
443+
let l:tw = &tw ? &tw : 72;
444+
443445
let l:count = a:count
444446

445447
if mode() == 'i' " gq was not pressed, but tw was set
446448
return 1
447449
endif
448450

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
450452
return 1
451453
endif
452454

@@ -460,9 +462,9 @@ function! Fixedgq(lnum, count)
460462

461463
let l:winview = winsaveview()
462464

463-
call cursor(a:lnum, 81)
465+
call cursor(a:lnum, l:tw + 1)
464466
let orig_breakpoint = searchpairpos(' ', '', '\.', 'bcW', '', a:lnum)
465-
call cursor(a:lnum, 81)
467+
call cursor(a:lnum, l:tw + 1)
466468
let breakpoint = searchpairpos(' ', '', '\.', 'bcW', s:skip_expr, a:lnum)
467469

468470
" No need for special treatment, normal gq handles edgecases better
@@ -473,7 +475,7 @@ function! Fixedgq(lnum, count)
473475

474476
" Try breaking after string
475477
if breakpoint[1] <= indent(a:lnum)
476-
call cursor(a:lnum, 81)
478+
call cursor(a:lnum, l:tw + 1)
477479
let breakpoint = searchpairpos('\.', '', ' ', 'cW', s:skip_expr, a:lnum)
478480
endif
479481

0 commit comments

Comments
 (0)