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>(
1616 denops : Denops ,
1717 group : VariableGroups ,
1818 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+ } ) ;
2125 // deno-lint-ignore no-explicit-any
22- return ( await denops . eval ( name ) ) as any ;
26+ return result as any ;
2327}
2428
2529export async function setVar < T = unknown > (
@@ -52,8 +56,8 @@ export class VariableHelper {
5256 this . #group = group ;
5357 }
5458
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 ) ;
5761 }
5862
5963 async set < T = unknown > ( prop : string , value : T ) : Promise < void > {
You can’t perform that action at this time.
0 commit comments