MiguelCastillo / Brackets-wsSanitizer

White Space Sanitizer for Brackets will help you keep your sanity by keeping your white spaces and tabs consistent
MIT License
36 stars 8 forks source link

Does not handle a mixture of leading tabs and spaces #7

Closed murrayju closed 9 years ago

murrayju commented 10 years ago

If a line contains a mixture of tabs and spaces, it will not always correctly sanitize the line. When the file is set to use spaces, only leading tabs will be converted to spaces. If a line begins with spaces, which are then immediately followed by some tab characters, the tabs will not be converted.

I run into this frequently when editing a file using the spaces setting, and using the tab key to add indentation. The editor inserts a tab character instead of spaces (this is probably a brackets issue really this is a bug in Vimdervar). I would like to see this plugin properly sanitize the line in this case.

MiguelCastillo commented 10 years ago

@murrayju Yeah I think this would be a nice addition. I will look into adding it in the next day or two.

PhiLhoSoft commented 9 years ago

+1, I just found out the bug...

MiguelCastillo commented 9 years ago

@murrayju @PhiLhoSoft Hey folks, I have added support for converting mixed tabs and spaces. The behavior is:

When converting from spaces to tabs, which is the use case with more complications:

  1. I will convert whatever spaces I can fit in a tab using the number of spaces per tabs configured in brackets.
  2. Any remaining spaces will be added to the end of the tab sequence.

To illustrate this... If you have configured Brackets to use 2 spaces per tab, and a line starts with 3 spaces, then 2 spaces will be converted to a single tab and the remaining space will be added at the end of the tab sequence. This is to make sure I don't break jsdocs type of arrangement.

These changes are in the master, so if you could be give it a try and give me any feedback before I publish these changes, that would be very much appreciated.

MiguelCastillo commented 9 years ago

Alright guys, I am closing this issue. If there is anything to be addressed, please open another issue with details. Thanks!!

PhiLhoSoft commented 9 years ago

Will try it as soon as possible. Felt the need this week, as a colleague using Eclipse (will try to convert them to Brackets! With your extensions!) had a bad setting and was adding tabs after the current indentation... :smile: Solved by de-indenting then re-indenting, but it is nicer if it is done transparently, as you did. Thanks!

MiguelCastillo commented 9 years ago

@PhiLhoSoft Great. Glad you found a way to get going :)