fsprojects / fantomas

FSharp source code formatter
https://fsprojects.github.io/fantomas
Other
770 stars 191 forks source link

[Feature request] Smarter ignore folder check #2900

Closed nojaf closed 4 months ago

nojaf commented 1 year ago

I propose we try to be smarter about ignored folders. The scenario I'm having right now is that I'm ignoring 6000 files all in one folder. I think it tries to find all files in that folder first to then decide on an individual level file level whether it should be ignored.

The existing way of Fantomas deals with this problem is:

https://github.com/fsprojects/fantomas/blob/e49b20b7f7fa020ad08f00cce9cdf32af1bfdbd2/src/Fantomas/Program.fs#LL68C1-L68C1

Pros and Cons

The advantages of making this adjustment to Fantomas are faster processing of ignored files in folders.

The disadvantages of making this adjustment to Fantomas are more checks per folder.

Examples

See Telplin at https://github.com/nojaf/telplin/commit/457eb04d8923d377ae53c71e8a4ec17d6dbeb0ba. It downloads the F# compiler and builds from source. All these files should be ignored.

Extra information

Estimated cost (XS, S, M, L, XL, XXL): S

Related suggestions: (put links to related suggestions here)

Affidavit (please submit!)

Please tick this by placing a cross in the box:

Please tick all that apply:

nojaf commented 1 year ago

@dawedawe one downside of this is that the ignored file count no longer add up.

Formatted │ 1 │ Ignored │ 5954 │ Unchanged │ 35 │ Errored │ 0

The Ignored part would no longer indicate the actual number of files. I'm not sure if this is necessarily a bad thing.

dawedawe commented 1 year ago

I'd prefer to not report a wrong number at all. That would just cause confusion, I think.

nojaf commented 1 year ago

Yeah, I was thinking along those lines as well. It might make sense to only report any ignored information in verbose mode. And skip the number.

Users would see a print in verbose mode when a file or folder was ignored.

This will require some shuffling in Fantomas.fsproj. We need to ignore files before the code Format tries to process them. Might also be a good moment to fully embrace System.IO.Abstractions

nojaf commented 4 months ago

I don't care anymore