Skip to content

Commit

Permalink
Add inputHistory
Browse files Browse the repository at this point in the history
  • Loading branch information
Shougo committed Nov 2, 2024
1 parent cfc87a3 commit 44ffca9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
15 changes: 14 additions & 1 deletion denops/ddu/ddu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export class Ddu {
#loader: Loader;
readonly #gatherStates = new Map<number, GatherState>();
#input = "";
#inputHistory: string[] = [];
#context: Context = defaultContext();
#options: DduOptions = defaultDduOptions();
#userOptions: UserOptions = {};
Expand Down Expand Up @@ -599,8 +600,8 @@ export class Ddu {
}

// Update current input
await this.setInput(denops, this.#input);
this.#context.doneUi = false;
this.#context.input = this.#input;
this.#context.maxItems = 0;

const filterResults = (await Promise.all(
Expand Down Expand Up @@ -985,6 +986,9 @@ export class Ddu {

// NOTE: :redraw is needed for command line
await denops.cmd("redraw");

// NOTE: Update inputHistory when uiAction
this.#updateInputHistory();
}

async itemAction(
Expand Down Expand Up @@ -1047,6 +1051,7 @@ export class Ddu {
items,
clipboard,
actionHistory,
inputHistory: this.#inputHistory,
});
}

Expand Down Expand Up @@ -1879,6 +1884,14 @@ export class Ddu {
}
});
}

#updateInputHistory() {
// NOTE: this.#inputHistory must be unique
this.#inputHistory.push(this.#input);
this.#inputHistory = Array.from(new Set(this.#inputHistory.reverse()))
.reverse();
console.log(this.#inputHistory);
}
}

function convertTreePath(treePath?: TreePath): string[] {
Expand Down
1 change: 1 addition & 0 deletions denops/ddu/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ export type ActionArguments<Params extends BaseParams> = {
items: DduItem[];
clipboard: Clipboard;
actionHistory: ActionHistory;
inputHistory: string[];
};

export type Actions<Params extends BaseParams> = Record<
Expand Down

0 comments on commit 44ffca9

Please sign in to comment.