feat(vscode): close HTML tags as they are typed in .wrn files
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
// WRN editor extension source hash: c9938fa5f643ca435ead2c8dd5b545c6906c37c0024cf3ea788666236c28ddb6
|
||||
// WRN editor extension source hash: 7721e499707f7fb9b0b52fe428de3033cd624fa508322ec795960af7b6d96da5
|
||||
// WRN editor extension generator hash: 456d1d614e44e5fb1f19b784176c09cf2ade9b64ef73a17934c2698150b62728
|
||||
"use strict";
|
||||
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
||||
@@ -22718,6 +22718,29 @@ async function recoverWrnLanguage(document) {
|
||||
console.warn("[wrnexus] unable to recover .wrn language association:", error instanceof Error ? error.message : String(error));
|
||||
}
|
||||
}
|
||||
function registerAutoCloseTags(context, client2) {
|
||||
const listener = vscode.workspace.onDidChangeTextDocument(async (event) => {
|
||||
if (event.document.languageId !== "wrn")
|
||||
return;
|
||||
if (!vscode.workspace.getConfiguration("wrnexus.html").get("autoClosingTags", true))
|
||||
return;
|
||||
const change = event.contentChanges[0];
|
||||
if (!change || change.text !== ">" && change.text !== "/")
|
||||
return;
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
if (!editor || editor.document !== event.document)
|
||||
return;
|
||||
const position = change.range.start.translate(0, change.text.length);
|
||||
const snippet = await client2.sendRequest("wrn/tagComplete", {
|
||||
textDocument: { uri: event.document.uri.toString() },
|
||||
position: { line: position.line, character: position.character }
|
||||
});
|
||||
if (typeof snippet !== "string" || !snippet)
|
||||
return;
|
||||
await editor.insertSnippet(new vscode.SnippetString(snippet), position);
|
||||
});
|
||||
context.subscriptions.push(listener);
|
||||
}
|
||||
async function activate(context) {
|
||||
for (const document of vscode.workspace.textDocuments)
|
||||
recoverWrnLanguage(document);
|
||||
@@ -22730,6 +22753,7 @@ async function activate(context) {
|
||||
debug: { module: module2, transport: TransportKind.stdio, options: { execArgv: ["--nolazy"] } }
|
||||
}, { documentSelector: [{ scheme: "file", language: WRN_LANGUAGE_ID }] });
|
||||
await client.start();
|
||||
registerAutoCloseTags(context, client);
|
||||
}
|
||||
async function deactivate() {
|
||||
const running = client;
|
||||
@@ -22737,4 +22761,4 @@ async function deactivate() {
|
||||
if (running)
|
||||
await running.stop();
|
||||
}
|
||||
module.exports = { activate, deactivate, recoverWrnLanguage };
|
||||
module.exports = { activate, deactivate, recoverWrnLanguage, registerAutoCloseTags };
|
||||
|
||||
Reference in New Issue
Block a user