microsoft / VSExtensibility

A repo for upcoming changes to extensibility in Visual Studio, the new extensibility model, and language server protocol.
MIT License
372 stars 49 forks source link

Nullable option for Setting.Integer #435

Open hahoyer opened 1 month ago

hahoyer commented 1 month ago

Is there a way to define a setting of type int??

Example: A maximum line length can be specified for the formatting of a document, but does not have to be. Then the line length is not limited.

At the moment I make do with a setting of type string, which I then convert. Another option would be to use the value -1 as a proxy for null. But these are all strange solutions, to be honest.

JoshuaBStevens commented 1 month ago

Providing a separate bool setting "Limit line lengths" (on which the "Maximum line length" int setting would be dependent) might be a more user-friendly configuration experience. But I'm interested to hear if you have reasons for avoiding that arrangement.

hahoyer commented 1 month ago

I don't think I'm able to explain it to you if you don't see it yourself. It reminds me a bit of the times when C# didn't have nullables. But then I guess I'll just have to live with it. Thank you for the further suggestion to mitigate the lack.

JoshuaBStevens commented 1 month ago

Sorry, I was a bit unclear. I understand why a nullable integer would be preferable from the extender's (i.e. your) perspective. And I realized after posting my initial response that Gladstone settings don't currently have any UI except direct JSON editing. So my question about the user configuration experience was understandably confusing.

Eventually VisualStudio.Extensibility settings will be included in the "Unified Settings" UI, which you can see today via Tools > Options after selecting Tools > Options Experience > Preview in a preview release of VS. In that UI, we feel that separate controls to enable the setting and to edit the setting's value would be more user-friendly than trying to combine both concepts into a single control.