microsoft / vscode-cpptools

Official repository for the Microsoft C/C++ extension for VS Code.
Other
5.4k stars 1.51k forks source link

C_Cpp.files.exclude not support glob patterns which files.exclude supported. #8960

Closed XIVN1987 closed 1 year ago

XIVN1987 commented 2 years ago

Bug type: Language Service

Describe the bug

Under directory hw/bsp, there is 63 sub-directory, i need only one of them (swm341). First, i write SWM341_USBD.code-workspace like this:

{
    "folders": [
        {
            "path": "."
        }
    ],
    "settings": {
        "files.exclude": {
            "hw/bsp/broadcom_32bit":true,
            "hw/bsp/broadcom_64bit":true,
            "hw/bsp/brtmm90x":true,
            "hw/bsp/d5035_01":true,
            "hw/bsp/da14695_dk_usb":true,
            "hw/bsp/da1469x_dk_pro":true,
            "hw/bsp/ea4088qs":true,
            "hw/bsp/ea4357":true,
            "hw/bsp/esp32s2":true,
            "hw/bsp/esp32s3":true,
            "hw/bsp/f1c100s":true,
            "hw/bsp/fomu":true,
            "hw/bsp/frdm_k32l2b":true,
            "hw/bsp/frdm_kl25z":true,
            "hw/bsp/gd32vf103":true,
            "hw/bsp/imxrt":true,
            "hw/bsp/kuiic":true,
            "hw/bsp/lpc15":true,
            "hw/bsp/lpc18":true,
            "hw/bsp/lpc54":true,
            "hw/bsp/lpc55":true,
            "hw/bsp/lpcxpresso11u37":true,
            "hw/bsp/lpcxpresso11u68":true,
            "hw/bsp/lpcxpresso1347":true,
            "hw/bsp/lpcxpresso1769":true,
            "hw/bsp/lpcxpresso51u68":true,
            "hw/bsp/mbed1768":true,
            "hw/bsp/mm32":true,
            "hw/bsp/msp430":true,
            "hw/bsp/msp432e4":true,
            "hw/bsp/ngx4330":true,
            "hw/bsp/nrf":true,
            "hw/bsp/nutiny_nuc121s":true,
            "hw/bsp/nutiny_nuc125s":true,
            "hw/bsp/nutiny_nuc126v":true,
            "hw/bsp/nutiny_sdk_nuc120":true,
            "hw/bsp/nutiny_sdk_nuc505":true,
            "hw/bsp/pic32mz":true,
            "hw/bsp/rp2040":true,
            "hw/bsp/rx":true,
            "hw/bsp/samd11":true,
            "hw/bsp/samd21":true,
            "hw/bsp/samd51":true,
            "hw/bsp/same54xplainedpro":true,
            "hw/bsp/same70_qmtech":true,
            "hw/bsp/same70_xplained":true,
            "hw/bsp/samg55xplained":true,
            "hw/bsp/saml2x":true,
            "hw/bsp/sltb009a":true,
            "hw/bsp/spresense":true,
            "hw/bsp/stm32f0":true,
            "hw/bsp/stm32f1":true,
            "hw/bsp/stm32f207nucleo":true,
            "hw/bsp/stm32f303disco":true,
            "hw/bsp/stm32f4":true,
            "hw/bsp/stm32f7":true,
            "hw/bsp/stm32g4":true,
            "hw/bsp/stm32h7":true,
            "hw/bsp/stm32l0538disco":true,
            "hw/bsp/stm32l4":true,
            "hw/bsp/tm4c123":true,
            "hw/bsp/xmc4000":true,
        }
    }
}

the files under these sub-directory will not show in vscode explore, and "go to definition" will navigate to files under swm341 as expected. all these work well.

But it's very troublesome to write out all sub-directory of hw/bsp. So I wrote it a different way.

{
    "folders": [
        {
            "path": "."
        }
    ],
    "settings": {
        "files.exclude": {
            "hw/bsp/{[^s]*,?[^w]*}": true
        }
    }
}

This time, vscode explore works well like above setting. But "go to definition" will list all funtions, not only functions under sub-directory swm341.

sean-mcmanus commented 2 years ago

Yeah, the [] and ^ syntax isn't currently handled by our exclusion parser.

A related VS Code issue is https://github.com/Microsoft/vscode/issues/869.

sullivanmj commented 2 years ago

I'd also like to see full support for glob syntax, particularly [] syntax. This is a problem when trying to exclude files from locations that are updated from a third party, where we know we will only care to see files with one particular pattern, but other files might be added as part of an update.

icegood commented 1 year ago

Yeah, the [] and ^ syntax isn't currently handled by our exclusion parser.

A related VS Code issue is microsoft/vscode#869.

didn't get why link is related? files.exclude has already supported [^..] as a group of symbols. While related issue connects to 'sequence' of symbols (and noone knows when it became supported). And what exclude syntax cpp parser supports for now at least for group? Why #9908 doesn't work?

sean-mcmanus commented 1 year ago

@icegood That link might not be related, but our exclusion implementation in cpptools doesn't parse the [] and ^ symbols like the implementation does in VS Code for files.exclude. The current implementation handles, *, ?, {}, , special characters. https://github.com/microsoft/vscode-cpptools/issues/9908 is a duplicate of this issue.

michelleangela commented 1 year ago

This is resolved in https://github.com/microsoft/vscode-cpptools/releases/tag/1.16.0.

michelleangela commented 1 year ago

Fix is now available in release version 1.16.2.