Skip to content

Commit

Permalink
added search in history for autocompletion (cryptic-game#39)
Browse files Browse the repository at this point in the history
  • Loading branch information
Akida31 committed Jan 16, 2021
1 parent f5967fb commit b6ef310
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/app/desktop/windows/terminal/terminal-states.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,12 @@ export abstract class CommandTerminalState implements TerminalState {

autocomplete(content: string): string {
return content
? Object.entries(this.commands)
? this.getHistory()
.reverse()
.find(n => n.startsWith(content)) ||
Object.entries(this.commands)
.filter(command => !('hidden' in command[1]))
.map(([name, _value]) => name)
.map(([name]) => name)
.sort()
.find(n => n.startsWith(content))
: '';
Expand Down

0 comments on commit b6ef310

Please sign in to comment.