Skip to content

Commit

Permalink
Use scoped configuration instead
Browse files Browse the repository at this point in the history
  • Loading branch information
davidxuang committed Feb 6, 2023
1 parent 71084d3 commit bee578b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,15 @@
"type": "boolean",
"default": false,
"markdownDescription": "If `PageTitle` is filled in `PAGE_INFO`, skip entering the title when posting."
},
"wikitext.scopedLuaIntegration": {
"type": "string",
"default": "auto",
"enum": [
"enabled",
"auto",
"disabled"
]
}
}
}
Expand Down
15 changes: 10 additions & 5 deletions src/extension-node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,18 @@ export function activate(context: vscode.ExtensionContext): void {
// Cite
context.subscriptions.push(vscode.commands.registerCommand("wikitext.citeWeb", addWebCite));

configureLuaLibrary("Scribunto", true);
configureLuaLibrary(
"Scribunto",
vscode.workspace.getConfiguration("wikitext").get<string>("scopedLuaIntegration") !== "disabled"
);
}

export function deactivate(): void {
console.log("Extension is inactive.");
configureLuaLibrary("Scribunto", false);

if (vscode.workspace.getConfiguration("wikitext").get<string>("scopedLuaIntegration") !== "enabled") {
configureLuaLibrary("Scribunto", false);
}
}

export function configureLuaLibrary(folder: string, enable: boolean) {
Expand All @@ -47,7 +53,6 @@ export function configureLuaLibrary(folder: string, enable: boolean) {
return;
}

// Use path.join to ensure the proper path seperators are used.
const folderPath = path.join(extensionPath, "EmmyLua", folder);
const config = vscode.workspace.getConfiguration("Lua");
const library: string[] | undefined = config.get("workspace.library");
Expand All @@ -57,7 +62,7 @@ export function configureLuaLibrary(folder: string, enable: boolean) {

if (library && extensionPath) {
// remove any older versions of our path
for (let i = library.length-1; i >= 0; i--) {
for (let i = library.length - 1; i >= 0; i--) {
const item = library[i];
const isSelfExtension = item.indexOf(extensionId) > -1;
const isCurrentVersion = item.indexOf(extensionPath) > -1;
Expand All @@ -77,6 +82,6 @@ export function configureLuaLibrary(folder: string, enable: boolean) {
library.splice(index, 1);
}
}
config.update("workspace.library", library, true);
config.update("workspace.library", library, false);
}
}

0 comments on commit bee578b

Please sign in to comment.