Skip to content

Commit

Permalink
fix: block invalid keyboard input, like Ctrl+D Alt+B
Browse files Browse the repository at this point in the history
  • Loading branch information
zthxxx committed Aug 22, 2021
1 parent ec14880 commit 7550561
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zsh-history-enquirer",
"version": "1.2.2",
"version": "1.2.3",
"description": "zsh history search plugin by enquirer",
"main": "index.js",
"bin": {
Expand Down
12 changes: 8 additions & 4 deletions src/historySearcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,11 @@ export default class HistorySearcher extends AutoComplete {
dispatch(ch: string, key?: Keypress) {
// https://github.com/enquirer/enquirer/blob/2.3.2/lib/keypress.js#L104
// https://github.com/enquirer/enquirer/blob/2.3.2/lib/keypress.js#L209
const { sequence } = key || {}
const { sequence, ctrl, meta, option } = key || {} as Keypress

// [BUG enquirer] bracketed paste mode
// content will be wrapped by the sequences `\e[200~` and `\e[201~`
// https://cirw.in/blog/bracketed-paste
// https://www.xfree86.org/current/ctlseqs.html#Bracketed%20Paste%20Mode
if (sequence === '\u001b[200') {
this.pastingStep = 'starting'
signale.debug('Keypress start pasting \\e[200~')
Expand All @@ -362,11 +363,14 @@ export default class HistorySearcher extends AutoComplete {
signale.debug(
'HistorySearcher dispatch',
{
char: stringify(ch),
char: ch,
key,
},
)
return super.dispatch(ch)

if (ch && !ctrl && !meta && !option) {
return super.dispatch(ch)
}
}

async complete() {
Expand Down

0 comments on commit 7550561

Please sign in to comment.