Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String-output #36

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

String-output #36

wants to merge 3 commits into from

Conversation

BobKerns
Copy link

In using the plugin to generate non-JSON/YAML files, I found it frustrating to only be able to see the output as a single JSON string.

This PR adds two new commands, and one related feature.

  • Jsonnet: Evaluate Expression (String)
  • Jsonnet: Evaluate File (String)
  • If the first line contains "Output: [name].", is used as the extension for the preview file. This enables syntax highlighting in the target language, if applicable.

I was unable to test the "Evaluate Expression (String)" variant, because I was unable to find an incantation for "Evaluate Expression" that did not give an error, for example, rejecting any simple input with a demand for an identifier. I don't know if this is an LSP bug or my misunderstanding, but Expression works the same as File so I believe my addition to be correct.

@CLAassistant
Copy link

CLAassistant commented Dec 20, 2023

CLA assistant check
All committers have signed the CLA.

@julienduchesne
Copy link
Member

I'll test it out! 👁️ 👁️

function suggestOutputExtension(): string {
const editor = window.activeTextEditor;
const header = editor.document.lineAt(0).text;
const ext = /output: \S*[.](?<ext>\S*)/i.exec(header)?.groups?.ext;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It does work but the Output: ... remains in the evaluated file which is a bit weird. Could it instead be a dialog option? (like the expression)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants