Skip to content

Commit f701d6a

Browse files
committed
Fix ext loadings
1 parent cb1582a commit f701d6a

File tree

2 files changed

+58
-31
lines changed

2 files changed

+58
-31
lines changed

denops/ddc/ddc.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,19 @@ export class Ddc {
516516
this.currentUiParams = uiParams;
517517
}
518518

519+
if (!ui) {
520+
console.log(`${options.ui} not found`);
521+
return;
522+
}
523+
524+
const input = denops.call("ddc#util#get_input", context.event);
525+
const mode = fn.mode(denops);
526+
if (context.input !== await input || context.mode !== await mode) {
527+
// Input is changed. Skip invalid completion.
528+
await this.hide(denops, context, options);
529+
return;
530+
}
531+
519532
await (async function write(ddc: Ddc) {
520533
await batch(denops, async (denops: Denops) => {
521534
await vars.g.set(denops, "ddc#_complete_pos", completePos);
@@ -529,14 +542,6 @@ export class Ddc {
529542
await ddc.show(denops, context, options, completePos, items);
530543
}
531544
})(this);
532-
533-
const input = denops.call("ddc#util#get_input", context.event);
534-
const mode = fn.mode(denops);
535-
if (context.input !== await input || context.mode !== await mode) {
536-
// Input is changed. Skip invalid completion.
537-
await this.hide(denops, context, options);
538-
return;
539-
}
540545
}
541546

542547
async show(

denops/ddc/ext.ts

Lines changed: 45 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,21 @@ export async function getUi(
4646
UiOptions,
4747
BaseParams,
4848
]> {
49-
if (options.ui.length === 0) {
49+
const name = options.ui;
50+
51+
if (name.length === 0) {
5052
return [
5153
undefined,
5254
defaultUiOptions(),
5355
defaultDummy(),
5456
];
5557
}
5658

57-
const ui = loader.getUi(options.ui);
58-
if (!ui) {
59-
if (!await loader.autoload(denops, "ui", options.ui)) {
60-
await printError(
61-
denops,
62-
`Not found ui: "${options.ui}"`,
63-
);
64-
}
59+
if (!loader.getUi(name) && !await loader.autoload(denops, "ui", name)) {
60+
await printError(
61+
denops,
62+
`Not found ui: "${options.ui}"`,
63+
);
6564

6665
return [
6766
undefined,
@@ -70,6 +69,15 @@ export async function getUi(
7069
];
7170
}
7271

72+
const ui = loader.getUi(name);
73+
if (!ui) {
74+
return [
75+
undefined,
76+
defaultUiOptions(),
77+
defaultDummy(),
78+
];
79+
}
80+
7381
const [uiOptions, uiParams] = uiArgs(options, ui);
7482

7583
await checkUiOnInit(ui, denops, uiOptions, uiParams);
@@ -90,14 +98,24 @@ export async function getSource(
9098
]
9199
> {
92100
const name = source2Name(userSource);
101+
102+
if (
103+
!loader.getSource(name) && !await loader.autoload(denops, "source", name)
104+
) {
105+
await printError(
106+
denops,
107+
`Not found source: ${name}`,
108+
);
109+
110+
return [
111+
undefined,
112+
defaultSourceOptions(),
113+
defaultDummy(),
114+
];
115+
}
116+
93117
const source = loader.getSource(name);
94118
if (!source) {
95-
if (!await loader.autoload(denops, "source", name)) {
96-
await printError(
97-
denops,
98-
`Not found source: ${name}`,
99-
);
100-
}
101119
return [
102120
undefined,
103121
defaultSourceOptions(),
@@ -134,26 +152,30 @@ export async function getFilter(
134152
]
135153
> {
136154
const name = filter2Name(userFilter);
137-
const filter = loader.getFilter(name);
138-
if (!filter) {
139-
if (!await loader.autoload(denops, "filter", name)) {
140-
await printError(
141-
denops,
142-
`Not found filter: ${name}`,
143-
);
144-
}
155+
156+
if (
157+
!loader.getFilter(name) && !await loader.autoload(denops, "filter", name)
158+
) {
159+
await printError(
160+
denops,
161+
`Not found filter: ${name}`,
162+
);
163+
145164
return [
146165
undefined,
147166
defaultFilterOptions(),
148167
defaultDummy(),
149168
];
150169
}
151170

171+
const filter = loader.getFilter(name);
172+
152173
const [filterOptions, filterParams] = filterArgs(
153174
filter,
154175
options,
155176
userFilter,
156177
);
178+
157179
await checkFilterOnInit(filter, denops, filterOptions, filterParams);
158180

159181
return [filter, filterOptions, filterParams];

0 commit comments

Comments
 (0)