Skip to content

Commit 27d0d41

Browse files
authored
feat: add a button to evaluate jsonnet files on titlebar; preview evaluation result in splited editor (#34)
1 parent 1c0abeb commit 27d0d41

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

package.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,14 @@
3636
"group": "navigation",
3737
"when": "false"
3838
}
39+
],
40+
"editor/title": [
41+
{
42+
"command": "jsonnet.evalFile",
43+
"alt": "jsonnet.evalFileYaml",
44+
"group": "navigation",
45+
"when": "resourceLangId == jsonnet"
46+
}
3947
]
4048
},
4149
"commands": [
@@ -47,12 +55,14 @@
4755
{
4856
"command": "jsonnet.evalFile",
4957
"title": "Jsonnet: Evaluate File",
50-
"enablement": "resourceLangId == jsonnet"
58+
"enablement": "resourceLangId == jsonnet",
59+
"icon": "$(open-preview)"
5160
},
5261
{
5362
"command": "jsonnet.evalFileYaml",
5463
"title": "Jsonnet: Evaluate File (YAML)",
55-
"enablement": "resourceLangId == jsonnet"
64+
"enablement": "resourceLangId == jsonnet",
65+
"icon": "$(open-preview)"
5666
},
5767
{
5868
"command": "jsonnet.evalExpression",

src/extension.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as path from 'path';
2-
import { commands, window, workspace, ExtensionContext, Uri, OutputChannel, TextEditor } from 'vscode';
2+
import { commands, window, workspace, ExtensionContext, Uri, OutputChannel, TextEditor, ViewColumn } from 'vscode';
33
import * as fs from 'fs';
44
import * as os from 'os';
55
import { stringify as stringifyYaml } from 'yaml';
@@ -95,7 +95,10 @@ function evalAndDisplay(params: ExecuteCommandParams, yaml: boolean): void {
9595
uri = Uri.file(tempYamlFile);
9696
fs.writeFileSync(tempYamlFile, yamlString);
9797
}
98-
window.showTextDocument(uri, { preview: true });
98+
window.showTextDocument(uri, {
99+
preview: true,
100+
viewColumn: ViewColumn.Beside
101+
});
99102
})
100103
.catch(err => {
101104
window.showErrorMessage(err.message);

0 commit comments

Comments
 (0)