fortran-lang / vscode-fortran-support

Fortran language support for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=fortran-lang.linter-gfortran
MIT License
207 stars 30 forks source link

bug: formatter custom arguments (findentArgs/fprettifyArgs) doesn't appear to work #1007

Closed irishismyname closed 7 months ago

irishismyname commented 10 months ago

Is there an existing issue for this?

Description

I've added

"fortran.formatting.findentArgs": ["-i4"],

to .vscode/settings.json in my project, but it doesn't seem to have any effect. To further test this I tried running findent independently with

findent -i4 < variables.f90 > newvariables.f90

and it seems to work as expected.

To further test this, I changed my settings.json file to

"fortran.formatting.findentArgs": ["-h"],

which I guess should have written the help content to my source file, but alas it did not.

Screenshots

No response

Expected Behaviour

findent arguments included in Argumentsfortran.formatting.findentArgs should be passed to findent.

Version of Modern Fortran

v3.2.0

Version of Visual Studio Code

v1.84.0

Platform and Architecture

Windows 11 22621

Additional Information

Using findent 4.2.6

irishismyname commented 10 months ago

Is there an easy way for me to see the actual findent call by the extension?

gnikit commented 10 months ago

Use the pre-release and set the log level to debug. You should be able to see the call in the Output pane.

PS I noticed this too a while back with fprettify but I forgot to make an issue and look into it. Might be related.

irishismyname commented 10 months ago

I switched to the pre-release version and enabled debug logging for VSCode, but the Modern Fortran Output Window isn't showing anything regarding findent. Is there a hidden option for logging level for this extension?

gnikit commented 10 months ago

Can you perform a document format and then copy-paste the contents of the Output pane here please.

irishismyname commented 10 months ago

Log Level Setting

image

Output

image

I get the output above each time I save the file, but nothing shows up when I run format document. I think it's working because I set VSCode to indent with 2 spaces but findent defaults to 3 and I'm getting 3.

irishismyname commented 10 months ago

Just got a notification in VSCode to reload for v3.4.2023102301. I'm getting 4 space indents instead of 3, but I still can't see the findent call or adjust the indentation level.

irishismyname commented 10 months ago

Update: findentArgs seem to be passed to findent call, but it's only updating when I start VSCode. If I change the setting without restarting, it will not update.

irishismyname commented 10 months ago

When I tried to debug this version on my machine I made these observations:

  1. When I modify my workspace settings.json, the condition to determine the change scope doesn't seem to evaluate true so the next line:
  2. this.config = assignment to update the config never seems to run. Even so, I think updating the config like this could be problematic as this might be an instance copy of LinterSettings.

My gut tells me the update method of the config needs to be run instead of this.config =, but I'm out of practice with JS and new to VSCode extension development.

gnikit commented 8 months ago

Thanks @irishismyname I noticed myself too, I will try and have a look (not sure when), but it's super annoying.