Skip to content

Commit f49f5fd

Browse files
committed
fix: restart from the matcher processor when switching sorter/renderer
1 parent 38e14af commit f49f5fd

File tree

1 file changed

+28
-8
lines changed

1 file changed

+28
-8
lines changed

denops/fall/picker.ts

+28-8
Original file line numberDiff line numberDiff line change
@@ -473,17 +473,27 @@ export class Picker<T extends Detail> implements AsyncDisposable {
473473
}
474474
this.#sortProcessor.sorterIndex = index;
475475
reserve((denops) => {
476-
this.#sortProcessor.start(denops, {
477-
items: this.#matchProcessor.items,
476+
// NOTE:
477+
// We need to restart from the matcher processor because
478+
// sorters and renderers applies changes in-place thus
479+
// the items would be polluted.
480+
this.#matchProcessor.start(denops, {
481+
items: this.#collectProcessor.items,
482+
query: this.#inputComponent.cmdline,
478483
});
479484
});
480485
break;
481486
}
482487
case "switch-sorter-at":
483488
this.#sortProcessor.sorterIndex = event.index;
484489
reserve((denops) => {
485-
this.#sortProcessor.start(denops, {
486-
items: this.#matchProcessor.items,
490+
// NOTE:
491+
// We need to restart from the matcher processor because
492+
// sorters and renderers applies changes in-place thus
493+
// the items would be polluted.
494+
this.#matchProcessor.start(denops, {
495+
items: this.#collectProcessor.items,
496+
query: this.#inputComponent.cmdline,
487497
});
488498
});
489499
break;
@@ -498,17 +508,27 @@ export class Picker<T extends Detail> implements AsyncDisposable {
498508
}
499509
this.#renderProcessor.rendererIndex = index;
500510
reserve((denops) => {
501-
this.#renderProcessor.start(denops, {
502-
items: this.#matchProcessor.items,
511+
// NOTE:
512+
// We need to restart from the matcher processor because
513+
// sorters and renderers applies changes in-place thus
514+
// the items would be polluted.
515+
this.#matchProcessor.start(denops, {
516+
items: this.#collectProcessor.items,
517+
query: this.#inputComponent.cmdline,
503518
});
504519
});
505520
break;
506521
}
507522
case "switch-renderer-at":
508523
this.#renderProcessor.rendererIndex = event.index;
509524
reserve((denops) => {
510-
this.#renderProcessor.start(denops, {
511-
items: this.#matchProcessor.items,
525+
// NOTE:
526+
// We need to restart from the matcher processor because
527+
// sorters and renderers applies changes in-place thus
528+
// the items would be polluted.
529+
this.#matchProcessor.start(denops, {
530+
items: this.#collectProcessor.items,
531+
query: this.#inputComponent.cmdline,
512532
});
513533
});
514534
break;

0 commit comments

Comments
 (0)