Skip to content

Commit af26b8f

Browse files
fesilysumneko
authored andcommitted
merge upsteam
fix globaluri bug
1 parent 2e59721 commit af26b8f

20 files changed

+97
-21
lines changed

changelog.md

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## Unreleased
44
<!-- Add all new changes here. They will be moved under a version at release -->
5+
* `FIX` Improve type narrow with **literal alias type** during completion and signature help
6+
* `NEW` Setting: `Lua.type.inferTableSize`: A Small Table array can be infered
57
* `NEW` Add custom repository support for addonManager. New configuration setting: `Lua.addonManager.repository_branch` and `Lua.addonManager.repository_path`
68

79
## 3.12.0

client/src/addon_manager/commands/enable.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { createChildLogger } from "../services/logging.service";
44
import { setConfig } from "../../languageserver";
55
import { WebVue } from "../panels/WebVue";
66
import { NotificationLevels } from "../types/webvue";
7-
import { ADDONS_DIRECTORY } from "../config";
7+
import { ADDONS_DIRECTORY, getStorageUri } from "../config";
88

99
type Message = {
1010
data: {
@@ -51,7 +51,7 @@ export default async (context: vscode.ExtensionContext, message: Message) => {
5151
for (const folder of selectedFolders) {
5252
try {
5353
const installLocation = vscode.Uri.joinPath(
54-
context.globalStorageUri,
54+
getStorageUri(context),
5555
"addonManager",
5656
ADDONS_DIRECTORY
5757
);

client/src/addon_manager/commands/getAddons.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import * as vscode from "vscode";
22
import { createChildLogger } from "../services/logging.service";
33
import addonManager from "../services/addonManager.service";
44
import { WebVue } from "../panels/WebVue";
5-
import { ADDONS_DIRECTORY } from "../config";
5+
import { ADDONS_DIRECTORY, getStorageUri } from "../config";
66

77
const localLogger = createChildLogger("Get Remote Addons");
88

99
export default async (context: vscode.ExtensionContext) => {
1010
WebVue.setLoadingState(true);
1111

1212
const installLocation = vscode.Uri.joinPath(
13-
context.globalStorageUri,
13+
getStorageUri(context),
1414
"addonManager",
1515
ADDONS_DIRECTORY
1616
);

client/src/addon_manager/commands/open.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import * as vscode from "vscode";
22
import { createChildLogger } from "../services/logging.service";
3-
import { ADDONS_DIRECTORY } from "../config";
3+
import { ADDONS_DIRECTORY, getStorageUri } from "../config";
44

55
const localLogger = createChildLogger("Open Addon");
66

77
export default async (
88
context: vscode.ExtensionContext,
99
message: { data: { name: string } }
1010
) => {
11-
const extensionStorageURI = context.globalStorageUri;
11+
const extensionStorageURI = getStorageUri(context);
1212
const uri = vscode.Uri.joinPath(
1313
extensionStorageURI,
1414
"addonManager",

client/src/addon_manager/commands/refreshAddons.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@ import * as vscode from "vscode";
22
import addonManager from "../services/addonManager.service";
33
import { ADDONS_DIRECTORY } from "../config";
44
import { WebVue } from "../panels/WebVue";
5+
import { getStorageUri } from "../config"
56

67
export default async (context: vscode.ExtensionContext) => {
78
WebVue.setLoadingState(true);
89

910
const installLocation = vscode.Uri.joinPath(
10-
context.globalStorageUri,
11+
getStorageUri(context),
1112
"addonManager",
1213
ADDONS_DIRECTORY
1314
);

client/src/addon_manager/config.ts

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import * as vscode from "vscode";
2+
13
// Development
24
export const DEVELOPMENT_IFRAME_URL = "http://127.0.0.1:5173";
35

@@ -6,6 +8,7 @@ export const REPOSITORY = {
68
PATH: "https://github.com/LuaLS/LLS-Addons.git",
79
DEFAULT_BRANCH: "main",
810
}
11+
912
export const REPOSITORY_OWNER = "carsakiller";
1013
export const REPOSITORY_NAME = "LLS-Addons";
1114
export const REPOSITORY_ISSUES_URL =
@@ -20,3 +23,12 @@ export const LIBRARY_SETTING = "Lua.workspace.library";
2023
export const PLUGIN_FILENAME = "plugin.lua";
2124
export const CONFIG_FILENAME = "config.json";
2225
export const INFO_FILENAME = "info.json";
26+
27+
let useGlobal = true
28+
export function getStorageUri(context: vscode.ExtensionContext) {
29+
return useGlobal ? context.globalStorageUri : (context.storageUri ?? context.globalStorageUri)
30+
}
31+
32+
export function setGlobalStorageUri(use: boolean) {
33+
useGlobal = use
34+
}

client/src/addon_manager/registration.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { createChildLogger, logger } from "./services/logging.service";
66
import dayjs from "dayjs";
77
import RelativeTime from "dayjs/plugin/relativeTime";
88
import { git, setupGit } from "./services/git.service";
9-
import { GIT_DOWNLOAD_URL, REPOSITORY } from "./config";
9+
import { GIT_DOWNLOAD_URL, REPOSITORY, setGlobalStorageUri } from "./config";
1010
import { NotificationLevels } from "./types/webvue";
1111
import * as languageServer from "../languageserver";
1212

@@ -32,11 +32,10 @@ export async function activate(context: vscode.ExtensionContext) {
3232
// update config
3333
const repository_path = globalConfig.get("repository_path") as string
3434
const repository_branch = globalConfig.get("repository_branch") as string
35-
let storageUri = context.globalStorageUri
3635
if ((repository_path || repository_branch) && context.storageUri) {
37-
REPOSITORY.PATH = repository_path ?? REPOSITORY.PATH
38-
REPOSITORY.DEFAULT_BRANCH = repository_branch ?? REPOSITORY.DEFAULT_BRANCH
39-
storageUri = context.storageUri
36+
REPOSITORY.PATH = !!repository_path ? repository_path : REPOSITORY.PATH
37+
REPOSITORY.DEFAULT_BRANCH = !!repository_branch ? repository_branch : REPOSITORY.DEFAULT_BRANCH
38+
setGlobalStorageUri(false)
4039
}
4140

4241

@@ -94,7 +93,7 @@ export async function activate(context: vscode.ExtensionContext) {
9493

9594
// Set up git repository for fetching addons
9695
try {
97-
setupGit(context, storageUri);
96+
setupGit(context);
9897
} catch (e: any) {
9998
const message =
10099
"Failed to set up Git repository. Please check your connection to GitHub.";

client/src/addon_manager/services/git.service.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import * as vscode from "vscode";
22
import simpleGit from "simple-git";
33
import filesystem from "./filesystem.service";
44
import { createChildLogger } from "./logging.service";
5-
import { REPOSITORY_NAME, REPOSITORY } from "../config";
5+
import { REPOSITORY_NAME, REPOSITORY, getStorageUri } from "../config";
66

77
const localLogger = createChildLogger("Git");
88

99
export const git = simpleGit({ trimmed: true });
1010

11-
export const setupGit = async (context: vscode.ExtensionContext, storageUri: vscode.Uri) => {
11+
export const setupGit = async (context: vscode.ExtensionContext) => {
1212
const storageURI = vscode.Uri.joinPath(
13-
storageUri,
13+
getStorageUri(context),
1414
"addonManager"
1515
);
1616
await filesystem.createDirectory(storageURI);

package.json

+12
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,18 @@
5656
"scope": "resource",
5757
"type": "boolean"
5858
},
59+
"Lua.addonManager.repository_branch": {
60+
"default": "",
61+
"markdownDescription": "%config.addonManager.repository_branch%",
62+
"scope": "resource",
63+
"type": "string"
64+
},
65+
"Lua.addonManager.repository_path": {
66+
"default": "",
67+
"markdownDescription": "%config.addonManager.repository_path%",
68+
"scope": "resource",
69+
"type": "string"
70+
},
5971
"Lua.codeLens.enable": {
6072
"default": false,
6173
"markdownDescription": "%config.codeLens.enable%",

package.nls.ja-jp.json

+1
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@
224224
"config.type.castNumberToInteger": "Allowed to assign the `number` type to the `integer` type.",
225225
"config.type.checkTableShape": "Strictly check the shape of the table.\n",
226226
"config.type.inferParamType": "When a parameter type is not annotated, it is inferred from the function's call sites.\n\nWhen this setting is `false`, the type of the parameter is `any` when it is not annotated.\n",
227+
"config.type.inferTableSize": "TODO: Needs documentation",
227228
"config.type.weakNilCheck": "When checking the type of union type, ignore the `nil` in it.\n\nWhen this setting is `false`, the `number|nil` type cannot be assigned to the `number` type. It can be with `true`.\n",
228229
"config.type.weakUnionCheck": "Once one subtype of a union type meets the condition, the union type also meets the condition.\n\nWhen this setting is `false`, the `number|boolean` type cannot be assigned to the `number` type. It can be with `true`.\n",
229230
"config.typeFormat.config": "Configures the formatting behavior while typing Lua code.",

package.nls.json

+1
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@
224224
"config.type.castNumberToInteger": "Allowed to assign the `number` type to the `integer` type.",
225225
"config.type.checkTableShape": "Strictly check the shape of the table.\n",
226226
"config.type.inferParamType": "When a parameter type is not annotated, it is inferred from the function's call sites.\n\nWhen this setting is `false`, the type of the parameter is `any` when it is not annotated.\n",
227+
"config.type.inferTableSize": "TODO: Needs documentation",
227228
"config.type.weakNilCheck": "When checking the type of union type, ignore the `nil` in it.\n\nWhen this setting is `false`, the `number|nil` type cannot be assigned to the `number` type. It can be with `true`.\n",
228229
"config.type.weakUnionCheck": "Once one subtype of a union type meets the condition, the union type also meets the condition.\n\nWhen this setting is `false`, the `number|boolean` type cannot be assigned to the `number` type. It can be with `true`.\n",
229230
"config.typeFormat.config": "Configures the formatting behavior while typing Lua code.",

package.nls.pt-br.json

+1
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@
224224
"config.type.castNumberToInteger": "Allowed to assign the `number` type to the `integer` type.",
225225
"config.type.checkTableShape": "对表的形状进行严格检查。\n",
226226
"config.type.inferParamType": "When the parameter type is not annotated, the parameter type is inferred from the function's incoming parameters.\n\nWhen this setting is `false`, the type of the parameter is `any` when it is not annotated.\n",
227+
"config.type.inferTableSize": "TODO: Needs documentation",
227228
"config.type.weakNilCheck": "When checking the type of union type, ignore the `nil` in it.\n\nWhen this setting is `false`, the `number|nil` type cannot be assigned to the `number` type. It can be with `true`.\n",
228229
"config.type.weakUnionCheck": "Once one subtype of a union type meets the condition, the union type also meets the condition.\n\nWhen this setting is `false`, the `number|boolean` type cannot be assigned to the `number` type. It can be with `true`.\n",
229230
"config.typeFormat.config": "Configures the formatting behavior while typing Lua code.",

package.nls.zh-cn.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"command.startServer": "Lua: (debug) 启动服务器",
66
"command.stopServer": "Lua: (debug) 停止服务器",
77
"config.addonManager.enable": "是否启用扩展的附加插件管理器(Addon Manager)",
8-
"config.addonManager.repository_branch": "插件管理器(Addon Manager)使用的git仓库分支",
9-
"config.addonManager.repository_path": "插件管理器(Addon Manager)使用的git仓库路径",
8+
"config.addonManager.repository_branch": "指定插件管理器(Addon Manager)使用的git仓库分支",
9+
"config.addonManager.repository_path": "指定插件管理器(Addon Manager)使用的git仓库路径",
1010
"config.codeLens.enable": "启用代码度量。",
1111
"config.color.mode": "着色模式。",
1212
"config.color.mode.Grammar": "语法着色。",
@@ -224,6 +224,7 @@
224224
"config.type.castNumberToInteger": "允许将 `number` 类型赋给 `integer` 类型。",
225225
"config.type.checkTableShape": "对表的形状进行严格检查。\n",
226226
"config.type.inferParamType": "未注释参数类型时,参数类型由函数传入参数推断。\n\n如果设置为 \"false\",则在未注释时,参数类型为 \"any\"\n",
227+
"config.type.inferTableSize": "TODO: Needs documentation",
227228
"config.type.weakNilCheck": "对联合类型进行类型检查时,忽略其中的 `nil`。\n\n此设置为 `false` 时,`numer|nil` 类型无法赋给 `number` 类型;为 `true` 是则可以。\n",
228229
"config.type.weakUnionCheck": "联合类型中只要有一个子类型满足条件,则联合类型也满足条件。\n\n此设置为 `false` 时,`number|boolean` 类型无法赋给 `number` 类型;为 `true` 时则可以。\n",
229230
"config.typeFormat.config": "配置输入Lua代码时的格式化行为",

package.nls.zh-tw.json

+1
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@
224224
"config.type.castNumberToInteger": "允許將 `number` 類型賦值給 `integer` 類型。",
225225
"config.type.checkTableShape": "对表的形状进行严格检查。\n",
226226
"config.type.inferParamType": "未注释参数类型时,参数类型由函数传入参数推断。\n\n如果设置为 \"false\",则在未注释时,参数类型为 \"any\"\n",
227+
"config.type.inferTableSize": "TODO: Needs documentation",
227228
"config.type.weakNilCheck": "When checking the type of union type, ignore the `nil` in it.\n\nWhen this setting is `false`, the `number|nil` type cannot be assigned to the `number` type. It can be with `true`.\n",
228229
"config.type.weakUnionCheck": "同位類型中只要有一個子類型滿足條件,則同位類型也滿足條件。\n\n此設定為 `false` 時,`number|boolean` 類型無法賦給 `number` 類型;為 `true` 時則可以。\n",
229230
"config.typeFormat.config": "Configures the formatting behavior while typing Lua code.",

setting/schema-ja-jp.json

+9
Original file line numberDiff line numberDiff line change
@@ -3331,6 +3331,9 @@
33313331
"inferParamType": {
33323332
"$ref": "#/properties/type.inferParamType"
33333333
},
3334+
"inferTableSize": {
3335+
"$ref": "#/properties/type.inferTableSize"
3336+
},
33343337
"weakNilCheck": {
33353338
"$ref": "#/properties/type.weakNilCheck"
33363339
},
@@ -3357,6 +3360,12 @@
33573360
"scope": "resource",
33583361
"type": "boolean"
33593362
},
3363+
"type.inferTableSize": {
3364+
"default": 10,
3365+
"markdownDescription": "TODO: Needs documentation",
3366+
"scope": "resource",
3367+
"type": "integer"
3368+
},
33603369
"type.weakNilCheck": {
33613370
"default": false,
33623371
"markdownDescription": "When checking the type of union type, ignore the `nil` in it.\n\nWhen this setting is `false`, the `number|nil` type cannot be assigned to the `number` type. It can be with `true`.\n",

setting/schema-pt-br.json

+9
Original file line numberDiff line numberDiff line change
@@ -3331,6 +3331,9 @@
33313331
"inferParamType": {
33323332
"$ref": "#/properties/type.inferParamType"
33333333
},
3334+
"inferTableSize": {
3335+
"$ref": "#/properties/type.inferTableSize"
3336+
},
33343337
"weakNilCheck": {
33353338
"$ref": "#/properties/type.weakNilCheck"
33363339
},
@@ -3357,6 +3360,12 @@
33573360
"scope": "resource",
33583361
"type": "boolean"
33593362
},
3363+
"type.inferTableSize": {
3364+
"default": 10,
3365+
"markdownDescription": "TODO: Needs documentation",
3366+
"scope": "resource",
3367+
"type": "integer"
3368+
},
33603369
"type.weakNilCheck": {
33613370
"default": false,
33623371
"markdownDescription": "When checking the type of union type, ignore the `nil` in it.\n\nWhen this setting is `false`, the `number|nil` type cannot be assigned to the `number` type. It can be with `true`.\n",

setting/schema-zh-cn.json

+11-2
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@
2222
},
2323
"addonManager.repository_branch": {
2424
"default": "",
25-
"markdownDescription": "插件管理器(Addon Manager)使用的git仓库分支",
25+
"markdownDescription": "指定插件管理器(Addon Manager)使用的git仓库分支",
2626
"scope": "resource",
2727
"type": "string"
2828
},
2929
"addonManager.repository_path": {
3030
"default": "",
31-
"markdownDescription": "插件管理器(Addon Manager)使用的git仓库路径",
31+
"markdownDescription": "指定插件管理器(Addon Manager)使用的git仓库路径",
3232
"scope": "resource",
3333
"type": "string"
3434
},
@@ -3331,6 +3331,9 @@
33313331
"inferParamType": {
33323332
"$ref": "#/properties/type.inferParamType"
33333333
},
3334+
"inferTableSize": {
3335+
"$ref": "#/properties/type.inferTableSize"
3336+
},
33343337
"weakNilCheck": {
33353338
"$ref": "#/properties/type.weakNilCheck"
33363339
},
@@ -3357,6 +3360,12 @@
33573360
"scope": "resource",
33583361
"type": "boolean"
33593362
},
3363+
"type.inferTableSize": {
3364+
"default": 10,
3365+
"markdownDescription": "TODO: Needs documentation",
3366+
"scope": "resource",
3367+
"type": "integer"
3368+
},
33603369
"type.weakNilCheck": {
33613370
"default": false,
33623371
"markdownDescription": "对联合类型进行类型检查时,忽略其中的 `nil`。\n\n此设置为 `false` 时,`numer|nil` 类型无法赋给 `number` 类型;为 `true` 是则可以。\n",

setting/schema-zh-tw.json

+9
Original file line numberDiff line numberDiff line change
@@ -3331,6 +3331,9 @@
33313331
"inferParamType": {
33323332
"$ref": "#/properties/type.inferParamType"
33333333
},
3334+
"inferTableSize": {
3335+
"$ref": "#/properties/type.inferTableSize"
3336+
},
33343337
"weakNilCheck": {
33353338
"$ref": "#/properties/type.weakNilCheck"
33363339
},
@@ -3357,6 +3360,12 @@
33573360
"scope": "resource",
33583361
"type": "boolean"
33593362
},
3363+
"type.inferTableSize": {
3364+
"default": 10,
3365+
"markdownDescription": "TODO: Needs documentation",
3366+
"scope": "resource",
3367+
"type": "integer"
3368+
},
33603369
"type.weakNilCheck": {
33613370
"default": false,
33623371
"markdownDescription": "When checking the type of union type, ignore the `nil` in it.\n\nWhen this setting is `false`, the `number|nil` type cannot be assigned to the `number` type. It can be with `true`.\n",

setting/schema.json

+9
Original file line numberDiff line numberDiff line change
@@ -3331,6 +3331,9 @@
33313331
"inferParamType": {
33323332
"$ref": "#/properties/type.inferParamType"
33333333
},
3334+
"inferTableSize": {
3335+
"$ref": "#/properties/type.inferTableSize"
3336+
},
33343337
"weakNilCheck": {
33353338
"$ref": "#/properties/type.weakNilCheck"
33363339
},
@@ -3357,6 +3360,12 @@
33573360
"scope": "resource",
33583361
"type": "boolean"
33593362
},
3363+
"type.inferTableSize": {
3364+
"default": 10,
3365+
"markdownDescription": "TODO: Needs documentation",
3366+
"scope": "resource",
3367+
"type": "integer"
3368+
},
33603369
"type.weakNilCheck": {
33613370
"default": false,
33623371
"markdownDescription": "When checking the type of union type, ignore the `nil` in it.\n\nWhen this setting is `false`, the `number|nil` type cannot be assigned to the `number` type. It can be with `true`.\n",

0 commit comments

Comments
 (0)