Skip to content

Commit

Permalink
Merge pull request #82 from kuuote/volatile
Browse files Browse the repository at this point in the history
RFC: 走ってるソースあってもvolatile効くようにしてみた
  • Loading branch information
Shougo authored Nov 1, 2023
2 parents 0fffa32 + c9c4abb commit b28f565
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 b28f565

Please sign in to comment.