Skip to content

Commit c0537d2

Browse files
authored
Merge pull request #81 from deathaxe/fix/st4-ruler-settings
Fix support for "rulers"
2 parents 9a0ad83 + cfda346 commit c0537d2

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

wrap_plus.py

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -510,20 +510,27 @@ def _determine_width(self, width):
510510
511511
:returns: The maximum line width.
512512
"""
513-
if width == 0 and self.view.settings().get('wrap_width'):
513+
514+
if width == 0:
514515
try:
515516
width = int(self.view.settings().get('wrap_width'))
516-
except TypeError:
517+
except (TypeError, ValueError):
517518
pass
518519

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
527534

528535
width = self.view.settings().get('WrapPlus.wrap_width', width)
529536

0 commit comments

Comments
 (0)