Skip to content

String-output#36

Open
BobKerns wants to merge 3 commits intografana:mainfrom
BobKerns:string-output
Open

String-output#36
BobKerns wants to merge 3 commits intografana:mainfrom
BobKerns:string-output

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
Collaborator

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
Collaborator

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