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
436 stars 53 forks source link

Autodetection of separators not working? #154

Open c06n opened 12 months ago

c06n commented 12 months ago

Maybe I am misunderstanding the feature, but Autodetection of separators needs some manual work to enable it.

(Otherwise, me and my colleagues enjoy your extension very much, thank you!!! Can I buy you a coffee?)

Expected

  1. I open the user settings and put in the separators, like so:

settings_autodetection

  1. I open my_file.csv containing that separator
  2. I see colors.

Observed

I do not see colors, like so:

tab_not_working

whitespace_not_working

Workaround

The issue seems to be the file association autodetection. Once I click on the file type association in VSC's bottom right corner, coloring works. Note the changed file type association.

tab_working

whitespace_working

Steps taken so far

Rainbow worked only for semicolon out of the box. I currently do not have specific file type associations in either user or workspace setting. I did try that at one point and it worked at described, but did seem to solve the autodetection issue.

For the comma separator, I had to explicitely select csv (no further associations). Before this, no coloring would be done.

comma_working

semicolon_working

Sys info

Rainbow

Name: Rainbow CSV Id: mechatroner.rainbow-csv Description: Highlight CSV and TSV files, Run SQL-like queries Version: 3.9.0 Publisher: mechatroner VS Marketplace Link: https://marketplace.visualstudio.com/items?itemName=mechatroner.rainbow-csv

VSC

Version: 1.84.2 (user setup) Commit: 1a5daa3a0231a0fbba4f14db7ec463cf99d7768e Date: 2023-11-09T10:51:52.184Z Electron: 25.9.2 ElectronBuildId: 24603566 Chromium: 114.0.5735.289 Node.js: 18.15.0 V8: 11.4.183.29-electron.0 OS: Windows_NT x64 10.0.19045

mechatroner commented 12 months ago

Hello, thank you for reporting this! You are right, the extension should automatically switch to TSV filetype. Yesterday I published a new version of Rainbow CSV (3.9.0) with some changes related to autodetection logic so this could be a reason why it stopped working. Still, I wasn't able to reproduce this on my laptop (the filetype correctly changes to TSV whey I open you file), so can I ask you to try to temporarily revert to version 3.8.0 (I attached a screenshot on how to do it just in case) and see if the previous version works correctly? install_another_version

mechatroner commented 12 months ago

Also could you please share what other extensions you have installed, and maybe try to see if this reproduces if you temporarily disable other extensions? There was another issue reported recently where the root cause was apparently a conflict with another extension (although I am still not sure which one it was).

c06n commented 12 months ago

Thanks for the quick reply. I have not found a solution but maybe I got one step futher.

I noticed one difference between the working VSC version and the not working version. In the working version, the language is shown as Dynamic CSV. When clicking on it, I can directly configure the separator. In the non-working version, I don't think I have ever seen Dynamic CSV. It only shows CSV or the specific configured subtype, such as CSV (whitespace).

Unforunately I have no idea about potential reasons for that. If you can give me any hint I'll investigate further.

Anyway, these are my installed and active extensions:

mechatroner commented 11 months ago

Thank you very much, this is very useful for me to know, especially the fact that the previous version had the same issue means that I don't have to roll back the last update just yet.

But also things got even more confusing, especially Dynamic CSV filetype - it shouldn't be enabled at all unless you enable it manually or the file has multiline-fields, so something might be wrong with the extension itself.

I am now working on adding a debugging logging option to the extension - something I should have done a long time ago, so once it is ready and published (by the end of this week I hope) I would really appreciate it if you could repeat the steps again with the logging on.

Also, I just learned that VSCode has the option to use different user profiles and even temporary profiles (a profile is a set of extensions + settings as I understand it) So in the meantime, if you have a few minutes to spare, could please try to do the following (I should have suggested it from the start but as I mentioned I just learned that this option exists):

  1. run Profiles: Create a temporary profile command - this should create a new temporary profile (or even better create a named profile e.g. rainbow_csv_test_1 using Profiles: Create Profile command that is persistent across vscode restarts, but then you would have to switch back to your main/default profile using Profiles: Swith profile command)
  2. Install Rainbow CSV
  3. Repeat your original steps by opening the file and see if the problem still reproduces (please let me know!)
  4. If the problem doesn't reproduce you can then optionally try to bisect the configuration that breaks it by installing additional extensions and/or copying settings from the main profile - you can copy the settings by running Preferences: Open User Settings (JSON) command - it opens a json files which you can use to copy and paste settings between the profiles.
c06n commented 11 months ago

Great, so the file type association seems to be the right direction. I'll try what you suggested as soon as I find the time, probably towards the end of the week.

c06n commented 11 months ago

I tried all your suggestions: created a named new profile and tried to reproduce the issue.

Perhaps interesting: When adding separators I had not used before, the file type says Dynamic CSV everytime now. When deleting and re-adding separators I had used before, the file type label shows the specific type, such as CSV (whitespace).

shash_working

quote_working

whitespace_working2

settings_json

mechatroner commented 10 months ago

Thanks for the update! I added a debug logging option in version 3.10.0 I also found and fixed a bug causing "Dynamic csv" highlighting to fail altogether with many custom color themes. If you were using a custom color theme this could have caused the problem.

c06n commented 10 months ago

Thanks for the fix and the debug logging option. I have used a one of the dark default themes but made some changes in the settings, so that's perhaps really the root cause.