@@ -4,10 +4,11 @@ import { parseYaml } from "./parsers/parseYaml";
44import { parseMarkdown } from "./parsers/parseMarkdown" ;
55import { parseDlConfig } from "./parsers/parseDlConfig" ;
66import { parseBatchConfig } from "./parsers/parseBatchConfig" ;
7- import { defaultMarkdown , inlineSuggestion , defaultYaml , markdownPreview } from "./commands" ;
7+ import { defaultMarkdown , inlineSuggestion , defaultYaml , markdownPreview , expandedTemplatesPreview } from "./commands" ;
8+ import { ExpandedTemplatesProvider , EXP_SCHEME } from "./fillTemplates" ;
89import { setExtensionContext } from "./contextStore" ;
910import { FileFixCodeActionProvider } from "./codeActionProvider" ;
10-
11+ import * as yaml from "js-yaml" ;
1112// should this be named yamlDiagnostics if also using markdown?
1213export const diagnosticCollection = vscode . languages . createDiagnosticCollection ( "yamlDiagnostics" ) ;
1314
@@ -51,12 +52,12 @@ export async function activate(context: vscode.ExtensionContext) {
5152 await parseDocument ( event ) ;
5253 }
5354 } ) ,
54- // for changing document
55- vscode . workspace . onDidChangeTextDocument ( async ( event ) => {
56- if ( event ?. document !== undefined ) {
57- parseDocument ( event ?. document ) ;
58- } ;
59- } ) ,
55+ // for changing document
56+ vscode . workspace . onDidChangeTextDocument ( async ( event ) => {
57+ if ( event ?. document !== undefined ) {
58+ parseDocument ( event ?. document ) ;
59+ } ;
60+ } ) ,
6061
6162 // When we switch to a document open in another tab
6263 vscode . window . onDidChangeActiveTextEditor ( async ( event ) => {
@@ -90,4 +91,22 @@ export async function activate(context: vscode.ExtensionContext) {
9091
9192 // Open Markdown preview
9293 context . subscriptions . push ( markdownPreview ) ;
94+
95+ // Open expanded templates preview
96+ const expandedProvider = new ExpandedTemplatesProvider ( ) ;
97+ context . subscriptions . push (
98+ vscode . workspace . registerTextDocumentContentProvider ( EXP_SCHEME , expandedProvider )
99+ ) ;
100+
101+ // Open preview command
102+ context . subscriptions . push (
103+ expandedTemplatesPreview
104+ ) ;
105+
106+ // Auto-refresh the preview when the source changes
107+ context . subscriptions . push (
108+ vscode . workspace . onDidChangeTextDocument ( ( e ) => {
109+ expandedProvider . refreshForSource ( e . document . uri ) ;
110+ } )
111+ ) ;
93112}
0 commit comments