Skip to content

Commit

Permalink
Add clearSelectedItems() for UI
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Sep 15, 2024
1 parent b65b10d commit 46bf47a
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 66 deletions.
2 changes: 1 addition & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"include": [
"denops/ddu/**/*.ts",
"denops/ddu/**/*.js"
],
]
},
"imports": {
},
Expand Down
110 changes: 45 additions & 65 deletions denops/ddu/base/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,85 +33,61 @@ export type OnAfterActionArguments<Params extends BaseParams> = {
uiParams: Params;
};

export type RefreshItemsArguments<Params extends BaseParams> = {
type BaseUiArguments<Params extends BaseParams> = {
denops: Denops;
context: Context;
options: DduOptions;
uiOptions: UiOptions;
uiParams: Params;
sources: SourceInfo[];
items: DduItem[];
};

export type CollapseItemArguments<Params extends BaseParams> = {
denops: Denops;
context: Context;
options: DduOptions;
uiOptions: UiOptions;
uiParams: Params;
item: DduItem;
};
export type RefreshItemsArguments<Params extends BaseParams> =
& BaseUiArguments<Params>
& {
sources: SourceInfo[];
items: DduItem[];
};

export type ExpandItemArguments<Params extends BaseParams> = {
denops: Denops;
context: Context;
options: DduOptions;
uiOptions: UiOptions;
uiParams: Params;
parent: DduItem;
children: DduItem[];
isGrouped: boolean;
};
export type CollapseItemArguments<Params extends BaseParams> =
& BaseUiArguments<Params>
& {
item: DduItem;
};

export type SearchItemArguments<Params extends BaseParams> = {
denops: Denops;
context: Context;
options: DduOptions;
uiOptions: UiOptions;
uiParams: Params;
item: DduItem;
};
export type ExpandItemArguments<Params extends BaseParams> =
& BaseUiArguments<Params>
& {
parent: DduItem;
children: DduItem[];
isGrouped: boolean;
};

export type RedrawArguments<Params extends BaseParams> = {
denops: Denops;
context: Context;
options: DduOptions;
uiOptions: UiOptions;
uiParams: Params;
};
export type SearchItemArguments<Params extends BaseParams> =
& BaseUiArguments<Params>
& {
item: DduItem;
};

export type QuitArguments<Params extends BaseParams> = {
denops: Denops;
context: Context;
options: DduOptions;
uiOptions: UiOptions;
uiParams: Params;
};
export type RedrawArguments<Params extends BaseParams> = BaseUiArguments<
Params
>;

export type VisibleArguments<Params extends BaseParams> = {
denops: Denops;
context: Context;
options: DduOptions;
uiOptions: UiOptions;
uiParams: Params;
tabNr: number;
};
export type QuitArguments<Params extends BaseParams> = BaseUiArguments<Params>;

export type WinidArguments<Params extends BaseParams> = {
denops: Denops;
context: Context;
options: DduOptions;
uiOptions: UiOptions;
uiParams: Params;
};
export type VisibleArguments<Params extends BaseParams> =
& BaseUiArguments<Params>
& {
tabNr: number;
};

export type UpdateCursorArguments<Params extends BaseParams> = {
denops: Denops;
context: Context;
options: DduOptions;
uiOptions: UiOptions;
uiParams: Params;
};
export type WinidArguments<Params extends BaseParams> = BaseUiArguments<Params>;

export type UpdateCursorArguments<Params extends BaseParams> = BaseUiArguments<
Params
>;

export type ClearSelectedItemsArguments<Params extends BaseParams> =
BaseUiArguments<Params>;

export abstract class BaseUi<Params extends BaseParams> {
apiVersion = 2;
Expand Down Expand Up @@ -155,6 +131,10 @@ export abstract class BaseUi<Params extends BaseParams> {

updateCursor(_args: UpdateCursorArguments<Params>): void | Promise<void> {}

clearSelectedItems(
_args: ClearSelectedItemsArguments<Params>,
): void | Promise<void> {}

abstract actions: UiActions<Params>;

abstract params(): Params;
Expand Down
10 changes: 10 additions & 0 deletions denops/ddu/ddu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1110,6 +1110,16 @@ export class Ddu {
const { signal } = this.#aborter;

if (ui) {
if (ui.clearSelectedItems) {
await ui.clearSelectedItems({
denops,
context: this.#context,
options: this.#options,
uiOptions,
uiParams,
});
}

await uiRedraw(
denops,
this.#uiRedrawLock,
Expand Down

0 comments on commit 46bf47a

Please sign in to comment.