Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coloring gets wrong after finding a single quote character in a raw C++ string #636

Closed
heriberto-delgado opened this issue Jun 8, 2023 · 6 comments

Comments

@heriberto-delgado
Copy link

Checklist

  • [ X ] This problem exists even with the setting "C_Cpp.enhancedColorization": "Disabled"

If Disabling that^ makes the problem go away, then follow this to make an issue on the C++ extension:
https://github.com/microsoft/vscode-cpptools/issues/new/choose

The code with a problem is:

#include "MyAwesomeDatabaseLibrary.h"
#include <string>
#include <iostream>

int main(int argc, char** argv)
{
    std::string plate = argv[1];

    AwesomeDBConnection conn;

    conn.Open("myconnectionstring");

    auto query = conn.Execute(R"sql(

        SELECT uid, part_name, install_date FROM CarParts
         WHERE plate = ')sql" + plate + "' ORDER BY install_date");

    for (const auto& entry : query)
    {
        std::cout << entry["uid"] << ": ";
        std::cout << entry["part_name"] << ", ";
        std::cout << entry["install_date"] << std::endl;
    }

    conn.Close();

    return 0;
}

It looks like:

Screenshot 2023-06-08 114206

It should look like:

(Well, not like that :D - after finding the first quote character in the raw C++ string, somehow, the process's interpretation of what is
a token and what is the inside of a string, gets reversed. It is as if raw strings are not correctly interpreted here.

@jeff-hykin
Copy link
Owner

Sadly this is the same problem as this and relates to a fundamental Textmate flaw, as discussed here. There is a hacky workaround, mentioned in that thread if you're feeling adventurous and want to have a stab at fixing this issue.

@JustTryingToGetSomeWorkDone

Just FYI, this was reported in February to the Arduino IDE project and they just ignored it.. "Not my bug, not my problem" mentality. Terrible. If you use a project's code in your project and someone finds a bug in your project as a result, you report the bug upstream. No? Should we suggest upstream reporting via downstream projects to Github or is that something that already exists but everyone is too lazy to use? How they can expect anyone to report bugs when they refuse to do so is beyond me. At least have pride in your own project, right?

arduino/arduino-ide#1857

jeff-hykin added a commit that referenced this issue Apr 16, 2024
@jeff-hykin
Copy link
Owner

jeff-hykin commented Apr 16, 2024

Just FYI, this was reported in February to the Arduino IDE project

  • Them locking the issue was bad (IMO)
  • Marking as off-topic is weird, I agree with you, I think it was pretty clearly on-topic
  • You reporting issues is a community service (👍 thanks for that)

Now ... with that out of the way @JustTryingToGetSomeWorkDone ...

_

If you use a project's code in your project and someone finds a bug in your project as a result, you report the bug upstream.
[they] should feel responsible for reporting bugs in the projects whose source they're using [...]

Out of respect/honor for Lasse Collin and others like him I want to say this very clearly:

No.

Unfunded FOSS devs have no special responsiblities whatsoever
They owe people nothing. Exactly, precisely, nothing.

Every second of their time is a gift.


For Arduino specifically, they are (maybe) funded through Arduino sales, so you can tell them it makes you not want to buy/use Arduinos. But they still have no obligation to even have a place to report issues.

Answers to your questions / comments

  1. At least have pride in your own project, right?

I understand why you might be thinking this, at one time I also didn't know. So I'll give you a pass. But, let me explain why telling maintainers to have a sense of pride is insulting and demotivating.

My repo, this one you're commenting on, is a dumpster fire. I WISH it was less popular. Not to say I'm not proud of any of my projects, but rather to say: everything runs on FOSS, which people maintain either just to keep the world spinning, or for one person's usecase (that they then donate so everyone can benefit). Not many projects are for bragging-rights.

With that explained, the only reason to talk about a lack of pride for FOSS projects is if you're trying to be malicious.


  1. Should we suggest upstream reporting via downstream projects to Github?

That would be great! Not only would I love that, but I know there are full time employees at Microsoft who just handle issues for VS Code -- mostly reporting them to upstream sources (like this repo). I'm sure they would also love that feature, and maybe they can convince Microsoft to add it to Github.


  1. How they can expect anyone to report bugs [...] it is beyond me.

    Should we suggest upstream reporting via downstream projects to Github [...]?

I'm happy to answer this.
The part where they said "You are welcome to report the bug to the upstream project: https://github.com/jeff-hykin/better-cpp-syntax" roughly translates to "We expect (either) you will report it (or it never gets reported)".

Said differently; they don't expect anyone to report bugs. They are just happy when someone does.



  1. [the Arduino IDE project] just ignored it..

  • They reproduced it
  • They found the exact source of the issue
  • They linked to the upstream source repository in case anyone wanted to volunteer more time by reporting it upstream

So no, they did not ignore it, even if they could've handled it better with less effort/time.

@jeff-hykin
Copy link
Owner

jeff-hykin commented Apr 16, 2024

@per1234 I will have to thank you for your comment here since the arduino thread is locked.

  1. I've used the Arduino IDE a lot over the years, the Java/Legacy Arduino IDE was probably one of the first editors I ever downloaded back in 2015. Its surreal to find out something I made is being used in the latest version.
  2. I use the major changes thread to reduce the work/breakages on downstreams. So you might want to watch there. I updated the Readme just now to include a message for downstream guys.
  3. From one FOSS dev to another, thanks adding for adding those extra instructions (quote below), I appreciate it
  • Verify the fault still occurs when using the development version of that project
  • Verify that there isn't an existing report in their issue tracker

Make sure to include the following in your report:

  • A minimal, reproducible, verifiable example (MCVE) of the fault (the sketch you shared here contains a huge amount of irrelevant code)
  • A reference to the section of the C++ specification that supports this odd omission of a space after the case statement as specification compliant

@jeff-hykin
Copy link
Owner

jeff-hykin commented Apr 16, 2024

With all that outa the way.

@heriberto-delgado this should be "fixed" on v1.22.0 and by "fixed" I mean I had to entirely pull out the SQL highlighting because, thanks to Textmate, there isn't a real way to fix that. The C++ will at least be highlighted correctly by default now. I'm going to mark this as done until the engine allows for a fix.

But, for anyone who wants SQL keyword highlighting; I added the string.quoted.double.raw.sql scope, which means its possible to make a VS Code extensions that adds SQL highlighting to that scope. Make one of those extensions, and you should be good to go.

@heriberto-delgado
Copy link
Author

I appreciate the effort, @jeff-hykin . Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants