SublimeText / TrailingSpaces

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

Toggling Trailing Spaces Highlighting resets color to null #160

Open RichardLitt opened 7 months ago

RichardLitt commented 7 months ago

I can't display trailing spaces in a Markdown file. Here are my prefs:

{
    "keys": ["ctrl+shift+."],
    "command": "delete_trailing_spaces",
    "scope_ignore": ["text.find-in-files", "source.build_output", "source.diff"],
    "highlight_color": "",
}

Whenever I reset the Toggle Trailing Spaces Highlighting option, highlight_color gets set back to "", no matter what I put in there before - region.reddish, error, invalid.illegal, a hex, or yellow. I can't figure out why this is happening, but I can't see highlighted final spaces on markdown at all.

Thank you for your work.

rchl commented 7 months ago

Default value of ignore_scope option ignores markdown since trailing spaces have special meaning in markdown. You can change that if you want: https://github.com/SublimeText/TrailingSpaces#ignore-scope

RichardLitt commented 7 months ago

I have changed that, by overriding it above in my settings. I'm not sure that's related to the highlight_color being reset.

rchl commented 7 months ago

The Trailing Spaces: Toggle Trailing Spaces Highlighting command toggles highlighting by changing the value of this setting back and forth.

Though looking at it now, it seems that the command will not be able to unset the empty value if ST is restarted after disabling highlighting.

I think the current toggle approach is not quite well done.

But if you manually remove highlight_color from your preferences then it should work (restart ST for good measure).

rchl commented 7 months ago

Note that the keys and command keys you can remove since those don't belong in preferences. Those are keybinding keys.

RichardLitt commented 7 months ago

Thanks, @rchl

I added keys and command because they were suggested in the readme, and I just wanted the preferences to work.

I manually removed highlight_color, and restarted. It doesn't show anything. Toggling only puts it back, also with an empty "" value. I still don't see it on my Markdown file. I'm not sure what I am doing wrong.

RichardLitt commented 7 months ago

Ok. It worked for a second. Using Toggle will put highlight_color back in the preferences object, and give it an empty value. After that, you can't remove it again - it'll just keep being there. This means that the only way to use the plugin, for me, is to delete that field, save it, restart, and never press Toggle again, as it disables the plugin permanently unless I manually edit it again and restart. That seems poorly done, to me.

RichardLitt commented 7 months ago

I can't figure out how to buy you a coffee - there's no sponsor button on your GitHub, and this plugin isn't on Open Collective. In any event, takk or dzięki.

rchl commented 7 months ago

I added keys and command because they were suggested in the readme, and I just wanted the preferences to work.

Yeah but it says to add it in a different file.

I agree the toggle behavior is a bug but it should work as long as you don't restart ST. If you restart ST with it set to "" then it won't be possible to return back to the correct value.

In any event, takk or dzięki.

good research