File tree Expand file tree Collapse file tree 1 file changed +17
-10
lines changed Expand file tree Collapse file tree 1 file changed +17
-10
lines changed Original file line number Diff line number Diff line change @@ -510,20 +510,27 @@ def _determine_width(self, width):
510
510
511
511
:returns: The maximum line width.
512
512
"""
513
- if width == 0 and self .view .settings ().get ('wrap_width' ):
513
+
514
+ if width == 0 :
514
515
try :
515
516
width = int (self .view .settings ().get ('wrap_width' ))
516
- except TypeError :
517
+ except ( TypeError , ValueError ) :
517
518
pass
518
519
519
- if width == 0 and self .view .settings ().get ('rulers' ):
520
- # try and guess the wrap width from the ruler, if any
521
- try :
522
- width = int (self .view .settings ().get ('rulers' )[0 ])
523
- except ValueError :
524
- pass
525
- except TypeError :
526
- pass
520
+ if width == 0 :
521
+ # try and guess the wrap width from the first ruler, if any
522
+ rulers = self .view .settings ().get ('rulers' )
523
+ if isinstance (rulers , list ) and len (rulers ) > 0 :
524
+ # use first ruler
525
+ ruler = rulers [0 ]
526
+ # extract column from rulers like [80, "solid"]
527
+ if isinstance (ruler , list ) and len (ruler ) > 0 :
528
+ ruler = ruler [0 ]
529
+ # ensure integer
530
+ try :
531
+ width = int (ruler )
532
+ except (TypeError , ValueError ):
533
+ pass
527
534
528
535
width = self .view .settings ().get ('WrapPlus.wrap_width' , width )
529
536
You can’t perform that action at this time.
0 commit comments