Skip to content

Commit bee578b

Browse files
committed
Use scoped configuration instead
1 parent 71084d3 commit bee578b

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,15 @@
266266
"type": "boolean",
267267
"default": false,
268268
"markdownDescription": "If `PageTitle` is filled in `PAGE_INFO`, skip entering the title when posting."
269+
},
270+
"wikitext.scopedLuaIntegration": {
271+
"type": "string",
272+
"default": "auto",
273+
"enum": [
274+
"enabled",
275+
"auto",
276+
"disabled"
277+
]
269278
}
270279
}
271280
}

src/extension-node.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,18 @@ export function activate(context: vscode.ExtensionContext): void {
3232
// Cite
3333
context.subscriptions.push(vscode.commands.registerCommand("wikitext.citeWeb", addWebCite));
3434

35-
configureLuaLibrary("Scribunto", true);
35+
configureLuaLibrary(
36+
"Scribunto",
37+
vscode.workspace.getConfiguration("wikitext").get<string>("scopedLuaIntegration") !== "disabled"
38+
);
3639
}
3740

3841
export function deactivate(): void {
3942
console.log("Extension is inactive.");
40-
configureLuaLibrary("Scribunto", false);
43+
44+
if (vscode.workspace.getConfiguration("wikitext").get<string>("scopedLuaIntegration") !== "enabled") {
45+
configureLuaLibrary("Scribunto", false);
46+
}
4147
}
4248

4349
export function configureLuaLibrary(folder: string, enable: boolean) {
@@ -47,7 +53,6 @@ export function configureLuaLibrary(folder: string, enable: boolean) {
4753
return;
4854
}
4955

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

5863
if (library && extensionPath) {
5964
// remove any older versions of our path
60-
for (let i = library.length-1; i >= 0; i--) {
65+
for (let i = library.length - 1; i >= 0; i--) {
6166
const item = library[i];
6267
const isSelfExtension = item.indexOf(extensionId) > -1;
6368
const isCurrentVersion = item.indexOf(extensionPath) > -1;
@@ -77,6 +82,6 @@ export function configureLuaLibrary(folder: string, enable: boolean) {
7782
library.splice(index, 1);
7883
}
7984
}
80-
config.update("workspace.library", library, true);
85+
config.update("workspace.library", library, false);
8186
}
8287
}

0 commit comments

Comments
 (0)