Skip to content

Commit

Permalink
走ってるソースあってもvolatile効くようにしてみた
Browse files Browse the repository at this point in the history
  • Loading branch information
kuuote committed Oct 31, 2023
1 parent 0fffa32 commit c9c4abb
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
18 changes: 18 additions & 0 deletions denops/ddu/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,24 @@ export function main(denops: Denops) {
async redraw(arg1: unknown, arg2: unknown): Promise<void> {
queuedName = ensure(arg1, is.String);
queuedRedrawOption = ensure(arg2, is.Record) as RedrawOption;
const ddu = getDdu(queuedName);
// Check volatile sources
const volatiles = [];
let index = 0;
for (const sourceArgs of ddu.getSourceArgs()) {
if (sourceArgs[0].volatile) {
volatiles.push(index);
}
index++;
}
if (
queuedRedrawOption?.refreshItems ||
queuedRedrawOption?.updateOptions ||
volatiles.length > 0
) {
ddu.cancelToRefresh();
ddu.resetCancelledToRefresh();
}

// NOTE: must be locked
await lock.lock(async () => {
Expand Down
4 changes: 2 additions & 2 deletions denops/ddu/ddu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -787,12 +787,12 @@ export class Ddu {
this.resetAbortController();
}

private cancelToRefresh() {
cancelToRefresh() {
this.cancelledToRefresh = true;
this.abortController.abort("cancelToRefresh");
}

private resetCancelledToRefresh() {
resetCancelledToRefresh() {
this.cancelledToRefresh = false;
this.resetAbortController();
}
Expand Down

0 comments on commit c9c4abb

Please sign in to comment.