File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -16,10 +16,14 @@ export async function getVar<T = unknown>(
16
16
denops : Denops ,
17
17
group : VariableGroups ,
18
18
prop : string ,
19
- ) : Promise < T > {
20
- const name = `${ group } :${ prop } ` ;
19
+ defaultValue ?: T ,
20
+ ) : Promise < T | null > {
21
+ const result = await denops . eval ( `get(${ group } :, name, value)` , {
22
+ name : prop ,
23
+ value : defaultValue ?? null ,
24
+ } ) ;
21
25
// deno-lint-ignore no-explicit-any
22
- return ( await denops . eval ( name ) ) as any ;
26
+ return result as any ;
23
27
}
24
28
25
29
export async function setVar < T = unknown > (
@@ -52,8 +56,8 @@ export class VariableHelper {
52
56
this . #group = group ;
53
57
}
54
58
55
- async get < T = unknown > ( prop : string ) : Promise < T > {
56
- return await getVar ( this . #denops, this . #group, prop ) ;
59
+ async get < T = unknown > ( prop : string , defaultValue ?: T ) : Promise < T | null > {
60
+ return await getVar ( this . #denops, this . #group, prop , defaultValue ) ;
57
61
}
58
62
59
63
async set < T = unknown > ( prop : string , value : T ) : Promise < void > {
You can’t perform that action at this time.
0 commit comments