mechatroner / vscode_rainbow_csv

🌈Rainbow CSV - VS Code extension: Highlight CSV and TSV files in different rainbow colors to make them more readable
MIT License
426 stars 51 forks source link

Limit visibility of editor context menu commands to show only for CSV files #109

Closed anthroid closed 2 years ago

anthroid commented 2 years ago

This prevents the "Set Header Line" and rainbow separator context menus from showing on all files and limits them to only activate when the current language is a CSV variant.

mechatroner commented 2 years ago

Thank you very much! I really appreciate your contribution and desire to improve the extension! The SetHeaderLine adjustment is really useful for removing the UI clutter, and I think that small improvements like this are super important in improving the overall perception of the extension. I will try to publish it ASAP because always showing this command in the context menu is obviously wrong, not sure why I haven't noticed that before.

I will have to revert the RainbowSeparator adjustment though because the main point of this command is to allow change language id for non-csv files, please let me know if I am missing something.

Thanks again!

anthroid commented 2 years ago

Thanks, I wasn't really sure about the RainbowSeparator command, but I was seeing it in the context menu when editing .c and .cpp sources, so it appeared to be another similar case. Would it make sense if it was only presented for plain text files? Something like this?

"when": "editorHasSelection && editorLangId == plaintext"

The rationale being that in most cases, if the user wants to define a separator and switch the language to CSV (if I'm understanding the purpose of this command correctly), they're either working on a file without a selected language ID (and therefore very likely editorLangId == plaintext), or they could directly select CSV from the language menu.

On the flip side, I would guess that the probability of someone needing to select a separator character and switch a file from an already configured syntax (like c, python, etc) to CSV is extremely low, meaning the command is likely showing up in most cases where it wouldn't be used.

Not sure if I'm understanding the intention of the RainbowSeparator command, just something to consider. In any case, thank you for all of your work on the extension, it makes working with CSVs much faster and easier.

anthroid commented 2 years ago

I have implemented this in my fork (https://github.com/anthroid/vscode_rainbow_csv/commit/83aa135d842658143e7d7ac05f6f8c9684edfe52), and it is working as expected as far as I can see. If there is some caveat with this approach that I'm missing, please let me know.

mechatroner commented 2 years ago

Great! Thank you. I just merged your fork.

One benefit of having it the way it was is "feature advertisement", but unfortunately right now in VSCode rainbow csv works only with a small set of predefined separators (because VSCode doesn't support dynamic syntax generation), so I guess this "advertisement" gives false expectations (in Sublime and Vim versions of "rainbow csv" any character or substring can serve as a separator which I think could be useful in certain situations even for non-plaintext files).

mechatroner commented 2 years ago

I just published both patches as version 2.2.0 :tada: Thanks again for your contributions!