TrailingSpaces icon indicating copy to clipboard operation
TrailingSpaces copied to clipboard

Toggling Trailing Spaces Highlighting resets color to null

Open RichardLitt opened this issue 1 year ago • 8 comments

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.

RichardLitt avatar Jan 09 '24 17:01 RichardLitt

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

rchl avatar Jan 09 '24 18:01 rchl

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

RichardLitt avatar Jan 09 '24 19:01 RichardLitt

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 avatar Jan 10 '24 20:01 rchl

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

rchl avatar Jan 10 '24 20:01 rchl

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 avatar Jan 10 '24 20:01 RichardLitt

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 avatar Jan 10 '24 20:01 RichardLitt

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.

RichardLitt avatar Jan 10 '24 20:01 RichardLitt

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

rchl avatar Jan 10 '24 22:01 rchl