better-cpp-syntax icon indicating copy to clipboard operation
better-cpp-syntax copied to clipboard

String literals aren't handled correctly with this sample C++ code

Open sean-mcmanus opened this issue 3 years ago • 1 comments

Checklist

  • [Yes] This problem exists even with the setting "C_Cpp.enhancedColorization": "Disabled"
  • [No] This bug exists for C
  • [Yes] This bug exists for C++
  • [?] This bug exists for Objective-C
  • [?] This bug exists for Objective-C++

The code with a problem is:

#define A
struct foo
{
    /*d*/ void func(const char* c)
    {
        #ifdef FOO
            int i;
        #else
            func("" A ")");
        #endif
    }
};

It looks like:

image

It should look like:

image

Originally reported at https://github.com/microsoft/vscode-cpptools/discussions/7627

sean-mcmanus avatar Jun 02 '21 18:06 sean-mcmanus

This one is going to be tough to fix correctly

  • Having the { on the next line makes it where textmate has no idea that it is inside of a function definition.
  • so then it thinks that func("" is part of a constuctor. Inside of the constuctor "" A isn't valid
  • instead its looking for type definitions and parameters

As with all things, there might be a hacky solution I'm not thinking of.

jeff-hykin avatar Jul 30 '21 23:07 jeff-hykin