-
-
Notifications
You must be signed in to change notification settings - Fork 283
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
<shift>+<up/down>
does not work in Mac Terminal
#206
Comments
Hi @kaustavghosh06, I copied the sort/prompt.js example and replaced it with code to match yours, and it's working for me (I'm also on Mac): 'use strict';
const { Sort } = require('enquirer');
const userList = ['abc', 'xyz'];
const prompt = new Sort({
name: 'sortNames',
message: 'Sort the user list in order of preference',
choices: userList
});
prompt.run()
.then(function(answer = []) {
console.log(answer);
})
.catch(console.error); To rule out any bugs that may have been fixed in the GitHub repository but not published to NPM yet, will you run your code using the latest on GitHub (either clone the repo and run in the same way the Also, if you have any additional information about your terminal, that might be helpful. |
@doowb This works on iterm on a Mac but won't work in the default Mac terminal. The root-cause is out here - https://github.com/enquirer/enquirer/blob/master/lib/keypress.js#L104 |
@kaustavghosh06 thank you for the additional details (I see that it also does not work for me in the Mac Terminal). However, the sequence that you put above is the same. Did you mean to put a different sequence? |
<shift>+<up/down>
does not work in Mac Terminal
@doowb Sorry, updated the sequence. |
As a workaround, I forked the package and changed the right/left keypresses to invoke the up and down functionality and the Mac terminal is able to detect shift +left/right arrows. Change in lib/keypress.js:
Hesitant to submit a PR with the above change, since I'm not certain if it'll break any other functionality in the lib which actually uses right/left arrows to perform some activities. This solution works for me as I'm just interested in the sort functionaility. |
@doowb I also work with @kaustavghosh06 and we're happy to submit a PR on this right now, but we don't want to break anything. We actually need this functionality very soon for a release and would prefer not to temporarily fork the project and just contribute a fix, but we understand if you need to think about this more. |
Thanks for looking into this more. A PR would be wonderful, but it would need to ensure other things didn't break (as @kaustavghosh06 mentioned). I don't think that the suggested change of the meaning of the escape sequence is the correct way to go, however, it lead me to investigate a little more and I think I have an option as a work around for you. Since you'd be willing to let the user know they could use the 'use strict';
const { Sort } = require('enquirer');
const userList = ['abc', 'xyz'];
const prompt = new Sort({
name: 'sortNames',
message: 'Sort the user list in order of preference',
hint: '(Use <shift>+<left/right> to sort)',
choices: userList,
shiftLeft(...args) {
return this.shiftUp(...args);
},
shiftRight(...args) {
return this.shiftDown(...args);
}
});
prompt.run()
.then(function(answer = []) {
console.log(answer);
})
.catch(console.error); This lets you use /edit: I updated the example to include the |
@doowb Thanks a bunch! We just tested this and it's working great. Really appreciate the help. We'll roll with this solution for now but let us know if there is something we should replace it with in the future. |
NP... I'll leave this open as a reminder to see if we can do anything. |
Thanks a lot @doowb for the workaround. |
I've verified that the issue persists. I'm on Windows 10 with enquirer v2.3.6, and it works fine in the embeded GitBash shell inside VS Code, for example, but doesn't work in the standalone GitBash shell. Tested with the most recent version, v2.4.1, and I'm getting the same results. @doowb's proposed solution of overrinding the default functionality doesn't work either :( |
I'm trying to use the Sort type of question for a CLI flow, like the following:
Here's my CLI display
But I'm not able to sort the above list with the instructions -
<shift> + up/down arrow
.I'm on a Mac system and not sure what I'm doing wrong out here.
The text was updated successfully, but these errors were encountered: