SublimeText / TrailingSpaces

Highlight trailing spaces and delete them in a flash.
MIT License
896 stars 94 forks source link

Highlighting Does No Work On Sublime Build 3143 #121

Closed justinlopez0 closed 4 years ago

justinlopez0 commented 6 years ago

After updating Sublime, the plugin's highlighting feature no longer work.

seppestas commented 6 years ago

Can confirm it stopped working (causing me to commit trailing spaces -.-).

Sublime text version 3.0 Build 3143, macOS version 10.12.6.

anbotero commented 6 years ago

Confirmed.

I tried copy-pasting all the settings from Default configuration file into the user settings file, and the only line that changes with each plugin activation is the trailing_spaces_highlight_color. Like, you might have changed both trailing_spaces_highlight_color and trailing_spaces_include_empty_lines values in the user settings file, and if you activate the plugin (super+alt+x in my case), the user settings file will reload, and trailing_spaces_highlight_color is the only value that will be left empty, other values will be left untouched.

tcaddy commented 6 years ago

Confirmed. on macOS, dev channel build 3148.

Equim-chan commented 6 years ago

Comfirmed, on Windows 10, build 3143. I checked console, it said the setting file was not found. Can that be the reason?

Traceback (most recent call last):
  File "D:\xxxx\Sublime Text Build 3143 x64\sublime_plugin.py", line 389, in run_callback
    expr()
  File "D:\xxxx\Sublime Text Build 3143 x64\sublime_plugin.py", line 522, in <lambda>
    run_callback('on_activated', callback, lambda: callback.on_activated(v))
  File "trailing_spaces in D:\xxxx\Sublime Text Build 3143 x64\Data\Installed Packages\TrailingSpaces.sublime-package", line 419, in on_activated
  File "trailing_spaces in D:\xxxx\Sublime Text Build 3143 x64\Data\Installed Packages\TrailingSpaces.sublime-package", line 440, in freeze_last_version
  File "./python3.3/codecs.py", line 896, in open
FileNotFoundError: [Errno 2] No such file or directory: 'D:\\xxxx\\Sublime Text Build 3143 x64\\Data\\Packages\\TrailingSpaces\\trailing_spaces.sublime-settings'
pensnarik commented 6 years ago

I have the same issue.trailing_spaces_highlight_color configuration parameter always reset to "" (empty string).

pensnarik commented 6 years ago

I found that plugin reads empty string as default value from settings in plugin_loaded() function. So you can fix this issue just adding these lines before DEFAULT_COLOR_SCOPE_NAME declaration:

    if current_highlighting_scope == '':
        current_highlighting_scope = "invalid"

I will try to find out the reason of this later. Maybe sublime.load_settings() method was changed in last Sublime build.

becomesaflame commented 6 years ago

Windows 10, build 3143. Clicking on Edit > Trailing Spaces > Highlight Regions has no effect. A message appears in the bottom bar saying "Highlighting of Trailing Spaces is disabled!"
Clicking the menu selection again has the same effect. Nothing shows up in the console other than "reloading settings Packages/User/trailing_spaces.sublime-settings" when I click it.

ecspresso commented 6 years ago

See issue #116. This fixes the problem, at least temporarily. Version 3.0 Build 3143.

I had this problem all of a sudden, can't remember when it started, but I basically just had to enter a value and restart. See : https://stackoverflow.com/questions/16916060#answer-23051790

Sublime Text 3 Build 3143 default settings

From Stack Overflow

It's a known bug - see their Issues page on GitHub.

I was able to get it working by starting Sublime with a non-blank string value for the setting trailing_spaces_highlight_color

Open Preferences > Package Settings > Trailing Spaces > Settings - User

Replace:
"trailing_spaces_highlight_color": ""
With:
"trailing_spaces_highlight_color": "invalid"

Restart Sublime.

Edit > Trailing Spaces > Highlight Regions should work as expected now.

If you restart Sublime, "trailing_spaces_highlight_color" must not be a blank string, otherwise it will stop working again. Repeat the steps above to fix.

As long as Sublime is started with a non-blank string value for trailing_spaces_highlight_color, the toggle highlight regions works.

It looks like the plugin is caching the value in the setting file when Sublime loads. If you make changes to the settings file and toggle highlighting, the original value is restored. Which is why you need to restart Sublime for setting changes to take effect.

Pictor13 commented 5 years ago

@ecspresso is right. Just tried now (set value "invalid" and restart right after) and it works!

Although I have no time atm to see why that happens, fix the code and make a PR :(

Nindaleth commented 5 years ago

Based on #125, for more recent Sublime Text 3 builds the "region.redish" might be a more fitting value than "invalid" for some color schemes.

Pictor13 commented 5 years ago

Update: to me the problem keeps reappearing regularly, even after fixing the settings.

The bug lays in persisting the setting in the code, assuming that the value is the one desired by the user, but looks like the settings are not loaded properly in some situations, so the plugin will find an empty string and re-persist that (why? 🤷‍♂️).

I think there should be a specific setting value that should be intended to disable trailing spaces. Using an empty string in trailing_spaces_highlight_color, interpreted as "disable" setting, leads to this weird behaviour. If not wanting to use a specific value then the logic in the code should be fixed. And I would add a specific/less-shady-setting to explicitly disable trailing space.

Although I am not sure what else the plugin still does when the trailing-spaces visualization is not enabled.

rchl commented 4 years ago

Duplicate of #65