ehuss / Sublime-Wrap-Plus

Enhanced "wrap lines" command for Sublime Text 2 or 3.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inconsistency encountered when word_wrap is "auto".

samueljohn opened this issue · comments

Not sure if this is a sublime bug or Wrap-Plus bug.

Symptom:

With "wrap_lines": 80 and "word_wrap": "auto" on, the following text

1.  Jerky prosciutto pork loin shankle, corned beef capicola pork pastrami egg a fatback short loin ground round.

will be wrapped and looks like so (with auto-wrap on!):

1.  Jerky prosciutto pork loin shankle, corned beef capicola pork pastrami egg
a
    fatback short loin ground round.

The reason why the "a" is on the new line here is that sublime's auto-wrap (soft-)wraps the "a" to a new line but it is the char No 80 (1-based counting).

Even if this looks more like a bug in sublime's word-wrap "auto" feature, I manually patched that line to read self._width = width-1.

There's a hidden configuration option to fix this. Try setting WrapPlus.wrap_col_diff to 1. I don't use automatic word wrapping, so I haven't tested it much. Sublime handles automatic word wrapping differently than the manual word wrapping. The automatic one includes the line ending in the character count, the manual one does not. WrapPlus follows the manual convention.

It was a while ago when I added this. Maybe it should auto-detect the line ending type to determine the offset. It should also probably just detect if word_wrap is set to "auto", though it all seems like it might be confusing.

Sounds to me like sublime text 2 (and 3) is acting strange here. But best what WordWrapPlus can do is - as you suggest - detect if word_wrap is set to "auto" and then WrapPlus.wrap_col_diff accordingly.

I put "WrapPlus.wrap_col_diff": 1 in Preferences.sublime-settings and it helped.

Is there a better place to put the setting?

Yes, your user preferences. You can also put it in your syntax preferences or project preferences.

I have added WrapPlus.include_line_endings and WrapPlus.wrap_width to deal with this.