jbockle / format-files

VS Code extension to format all files in workspace
41 stars 13 forks source link

extensionsToInclude setting glob pattern generation seems to fail. #20

Closed julian-poidevin closed 3 years ago

julian-poidevin commented 3 years ago

Using the following settings :

"formatFiles.extensionsToInclude": "c,h",
"formatFiles.excludePattern": "**/.vscode,**/Middlewares/Third_Party/**,**/Unit_testing/Unity/**,**/Drivers/**,**/*stm32f4xx*.*,**/*freertos*.*,**/FreeRTOSConfig.h",

And launching the formatFiles.start.workspace command, the extnesion does not find any files to format :

[14:52:51 info.] (ext) Starting Format Files - Workspace
[14:52:51 info.] (validate-in-workspace) found workspace folders: Gpu
[14:52:51 info.] (validate-in-workspace) workspace is valid!
[14:52:51 info.] (select-workspace-folder) a single workspace folder was found, selecting Gpu
[14:52:51 info.] (get-files) creating include glob
[14:52:51 info.] (get-files)    **/*.c,h
[14:52:51 info.] (get-files) creating exclude glob
[14:52:51 info.] (get-files)        including files.exclude globs
[14:52:51 info.] (get-files)            {**/.vscode,**/Middlewares/Third_Party/**,**/Unit_testing/Unity/**,**/Drivers/**,**/*stm32f4xx*.*,**/*freertos*.*,**/FreeRTOSConfig.h,**/.git,**/.svn,**/.hg,**/CVS,**/.DS_Store}
[14:52:51 info.] (get-files) searching for files in workspace folder 'Gpu' include:**/*.c,h exclude:{**/.vscode,**/Middlewares/Third_Party/**,**/Unit_testing/Unity/**,**/Drivers/**,**/*stm32f4xx*.*,**/*freertos*.*,**/FreeRTOSConfig.h,**/.git,**/.svn,**/.hg,**/CVS,**/.DS_Store}
[14:52:51 info.] (get-files) Discovered 0 files to format
[14:52:54 info.] (confirm-start) result: undefined
[14:52:54 error] (ext) OperationAborted::

Whereas launching from formatFiles.start.fromGlob command, using respevely **/*.c and **/*.h pattern, the extension finds the files :

[14:57:23 info.] (ext) Starting Format Files - By Glob Pattern
[14:57:23 info.] (validate-in-workspace) found workspace folders: Gpu
[14:57:23 info.] (validate-in-workspace) workspace is valid!
[14:57:23 info.] (select-workspace-folder) a single workspace folder was found, selecting Gpu
[14:57:26 info.] (request-glob) glob entered: **/*.c
[14:57:27 info.] (workspace-validator) Use default excludes?: Yes - Use 'formatFiles' settings in vscode
[14:57:27 info.] (get-files) creating exclude glob
[14:57:27 info.] (get-files)        including files.exclude globs
[14:57:27 info.] (get-files)            {**/.vscode,**/Middlewares/Third_Party/**,**/Unit_testing/Unity/**,**/Drivers/**,**/*stm32f4xx*.*,**/*freertos*.*,**/FreeRTOSConfig.h,**/.git,**/.svn,**/.hg,**/CVS,**/.DS_Store}
[14:57:27 info.] (get-files) searching for files in workspace folder 'Gpu' include:**/*.c exclude:{**/.vscode,**/Middlewares/Third_Party/**,**/Unit_testing/Unity/**,**/Drivers/**,**/*stm32f4xx*.*,**/*freertos*.*,**/FreeRTOSConfig.h,**/.git,**/.svn,**/.hg,**/CVS,**/.DS_Store}
[14:57:27 info.] (get-files) Discovered 29 files to format
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Unit_testing\Test_suites\TS_helloworld\src\TS_HW.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Unit_testing\Test_suites\TS_GLOBAL\src\UTmain.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Middlewares\User\Src\array_converter.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Middlewares\User\Src\utils.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Middlewares\User\Src\moteur_graphe.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Middlewares\User\Src\moteur_can.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Middlewares\User\Src\crc8.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Middlewares\User\Src\crc32.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Middlewares\User\Src\crc16.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\API_Drivers\Src\api_driver_timer_synchrone.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\API_Drivers\Src\api_driver_i2c_generique.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\API_Drivers\Src\api_driver_gpio.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\API_Drivers\Src\api_driver_can.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Application\Graphe\Src\g_init.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Application\Graphe\Src\g_gestion_dc.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Application\Graphe\Src\g_etat.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Application\Graphe\Src\g_can.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Application\Data\Src\def_etat.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Application\Data\Src\def_data.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Application\App\Src\factory.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Application\App\Src\api_led.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Application\App\Src\api_graphe.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Application\App\Src\api_gpio.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Application\App\Src\api_gestion_puissance.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Application\App\Src\api_gestion_mesure.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Application\App\Src\api_defaut.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Application\App\Src\api_can.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Application\Configuration\Src\main.c
[14:57:27 info.] (get-files)    c:\repo\EmbeddedC\Gpu\Application\Configuration\Src\configurateur.c
[14:57:37 info.] (confirm-start) result: Nevermind
[14:57:37 error] (ext) OperationAborted::Nevermind
jbockle commented 3 years ago

I need to add some better docs there. Its just appending to a glob so you should be able to use {.c,.h}

julian-poidevin commented 3 years ago

I'm sorry I dont get your answer, why does my "formatFiles.extensionsToInclude": "c,h", setting does not find any files ? See below :

[14:52:51 info.] (get-files) Discovered 0 files to format
julian-poidevin commented 3 years ago

I think the following code is not working as intended : https://github.com/jbockle/format-files/blob/31b375a6bbc2d51f952447b7a66d914a26fd21e8/src/ext/queries/get-files.ts#L28-L32

When providing the following setting : formatFiles.extensionsToInclude": "c,h", the global pattern generated is **/*.{.c,.h} whereas it should be **/*.{c,h} (without the dots before each extension).

jbockle commented 3 years ago

you are on the right track, instead of "c,h" do "{c,h}"

julian-poidevin commented 3 years ago

That worked ! Thanks !