Skip to content

Commit 894a291

Browse files
committed
💪 use defaultValue of internal methods
1 parent 62d490e commit 894a291

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

Diff for: option/_utils.ts

+28-10
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class OptionImpl<T> implements GlobalOrLocalOption<T> {
1717
}
1818

1919
async get(denops: Denops): Promise<T> {
20-
const result = await options.get(denops, this.#name);
21-
return this.#coerce(result ?? this.#defaultValue);
20+
const result = await options.get(denops, this.#name, this.#defaultValue);
21+
return this.#coerce(result);
2222
}
2323

2424
set(denops: Denops, value: T): Promise<void> {
@@ -30,8 +30,12 @@ class OptionImpl<T> implements GlobalOrLocalOption<T> {
3030
}
3131

3232
async getGlobal(denops: Denops): Promise<T> {
33-
const result = await globalOptions.get(denops, this.#name);
34-
return this.#coerce(result ?? this.#defaultValue);
33+
const result = await globalOptions.get(
34+
denops,
35+
this.#name,
36+
this.#defaultValue,
37+
);
38+
return this.#coerce(result);
3539
}
3640

3741
setGlobal(denops: Denops, value: T): Promise<void> {
@@ -43,8 +47,12 @@ class OptionImpl<T> implements GlobalOrLocalOption<T> {
4347
}
4448

4549
async getLocal(denops: Denops): Promise<T> {
46-
const result = await localOptions.get(denops, this.#name);
47-
return this.#coerce(result ?? this.#defaultValue);
50+
const result = await localOptions.get(
51+
denops,
52+
this.#name,
53+
this.#defaultValue,
54+
);
55+
return this.#coerce(result);
4856
}
4957

5058
setLocal(denops: Denops, value: T): Promise<void> {
@@ -56,17 +64,27 @@ class OptionImpl<T> implements GlobalOrLocalOption<T> {
5664
}
5765

5866
async getBuffer(denops: Denops, bufnr: number): Promise<T> {
59-
const result = await getbufvar(denops, bufnr, `&${this.#name}`);
60-
return this.#coerce(result ?? this.#defaultValue);
67+
const result = await getbufvar(
68+
denops,
69+
bufnr,
70+
`&${this.#name}`,
71+
this.#defaultValue,
72+
);
73+
return this.#coerce(result);
6174
}
6275

6376
setBuffer(denops: Denops, bufnr: number, value: T): Promise<void> {
6477
return setbufvar(denops, bufnr, `&${this.#name}`, value);
6578
}
6679

6780
async getWindow(denops: Denops, winnr: number): Promise<T> {
68-
const result = await getwinvar(denops, winnr, `&${this.#name}`);
69-
return this.#coerce(result ?? this.#defaultValue);
81+
const result = await getwinvar(
82+
denops,
83+
winnr,
84+
`&${this.#name}`,
85+
this.#defaultValue,
86+
);
87+
return this.#coerce(result);
7088
}
7189

7290
setWindow(denops: Denops, winnr: number, value: T): Promise<void> {

0 commit comments

Comments
 (0)