microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.16k stars 28.84k forks source link

[json] UI for anyOf settings tooltips needs improvement #109984

Open lf- opened 3 years ago

lf- commented 3 years ago

Version: 1.50.1 (system setup) Commit: d2e414d9e4239a252d1ab117bd7067f125afd80a Date: 2020-10-13T15:06:15.712Z Electron: 9.2.1 Chrome: 83.0.4103.122 Node.js: 12.14.1 V8: 8.3.110.13-electron.0 OS: Windows_NT x64 10.0.19041

Note: I am aware of #92823, but this is a larger issue with settings tooltips for anyOf settings. I am about to go fix that specific case by writing extra description for that particular setting.

Steps to Reproduce:

  1. Go into the user settings page and search for font ligatures; click on the item there
  2. You get this, and think you can only turn it on/off: [caption: "Enable/Disable font ligatures" in a tooltip for editor.fontLigatures on a line with "editor.fontLigatures": null] image
  3. Find out somehow that it allows strings and get this [also, assuming you think of mousing over it once you put the RHS in]? But what's a font-feature-settings [requires the user has domain knowledge of CSS]? [caption: "Explicit font-feature-settings" in a tooltip for editor.fontLigatures on a line with "editor.fontLigatures": ""] image

Additionally, if you were to type in "editor.fontLigatures" and see the intellisense, it wouldn't help much: [caption: "Configures font ligatures or font features" in an intellisense box as a suggestion for "editor.font"]

image

A PR is incoming to change all three of these strings to mitigate the UI issue for editor.fontLigatures specifically, but the UI should also be changed in these tooltips so it shows the description (last screenshot) above both the string and boolean setting types. I'm not proficient enough in TypeScript/VSCode internals to know where to start investigating the tooltip, so I'd appreciate if someone takes this on.

Does this issue occur when all extensions are disabled?: Yes/No Yes

vscodebot[bot] commented 3 years ago

(Experimental duplicate detection) Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

lf- commented 3 years ago

Thanks vscodebot! Part of this is indeed a duplicate which my own search failed to find. I shall change the title so it covers the general tooltip problem.

jnsnow commented 3 years ago

I am also seeing this problem, and would like to hear if anyone has suggestions for workarounds in writing schema that describe existing formats that cannot be easily changed.

When using the "anyOf" construct in json-schema to declare that an object can be one of any of several types, VSCode appears to choose the first branch as its default, meaning that the tooltips can be misleading.

It is not immediately clear how this might be rectified however. One small improvement might be giving a possible values enumeration list akin to the key-selection popups. e.g.;

{ "ThisKeyUses-anyOf": ▮ }

Where the ▮ represents the user's text editing cursor. This might pop up a contextual list like:

"FooType >"
"BarType >"
"BazType >"
"object >"
"array >"
"string >"

where the ">" is a hint to show the description (if any) for that subschema. Subschema without titles just get described generically ("object", "string", "array"). I'd expect this to be the same sort of list when you hit ctrl+spacebar in the same location.

Though, given the flexibility of the JSON-Schema in general, it's hard to say if that's actually a good design choice.