The feature can only be triggered when a valid KCL file is in the active editor:
If the KCL file is under a compile stack (kcl.mod or kcl.yaml), the preview button and command will be shown. And the YAML representation of the stack configuration will be previewed.
If the KCL file is not under a stack, the preview button and command will be shown. And the YAML representation of that single file will be previewed.
If the configuration is not valid (contains some syntax error or could not pass the check validation):
the preview command in the palette, the button in the toolbar, and the command in the editor tab will still be shown but should be disabled(with gray font and can not be triggered). And there should be a warning on that command or button to intimate that the code needs to be fixed first.
If the user triggers the preview with the shortcut, then the preview panel should be displayed with empty data content, but a warning to intimate the code needs to be fixed first.
In other situations, that preview button and command will not be displayed.
support viewing the corresponding YAML data of a KCL configuration
single Yaml view: could be triggered by:
shortcut: ⇧⌘V
right-click on the editor Tab and select Open Preview (⇧⌘V)
Command Palette: KCL: Data Preview (⇧⌘V)
side-by-side live view. could be triggered by:
shortcut: ⌘K V
clicking the preview button in the editor toolbar
command Palette: KCL: Open Preview to the Side⌘K V
Enhancement
The feature can only be triggered when a valid KCL file is in the active editor:
support viewing the corresponding YAML data of a KCL configuration
⇧⌘V
Open Preview (⇧⌘V)
KCL: Data Preview (⇧⌘V)
⌘K V
⌘K V
Reference
Similar feature for helm chart template(from vscode kubernetes extension maintained by microsoft), could be triggered by command:
Helm: Preview Template
This feature is implemented using vscode webview, and the yaml format preview doesn't support highlight or folding.