-
-
Notifications
You must be signed in to change notification settings - Fork 625
fix(#2370): Better "y/N" prompts #2377
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
Conversation
…te cases) and made it so that the copy paste same name conflict defaults to R(ename)
I've thought about it and the "no" condition is unnecessary as everything that is not "y" is a no condition. I'm closing this PR and would be reopening this after I've fixed this issue. |
Thanks for taking the time. This one is indeed more difficult than it appears. |
I've removed all "No" conditions as they are not needed as everything that is not a "y" or "yes" entered is a no condition. And would delete/replace the files |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks for your contribution. This greatly enhances UX.
- maybe address default
r
- Please update
lib.prompt
to convert the callback's item_short to lowercase. Users may start using uppercase to match the prompt.
local prompt_input = prompt_select .. " y/n/r(ename): " | ||
lib.prompt(prompt_input, prompt_select, { "y", "n", "r" }, { "Yes", "No", "Rename" }, function(item_short) | ||
local prompt_input = prompt_select .. " R(ename)/y/n: " | ||
lib.prompt(prompt_input, prompt_select, { "r", "y" }, { "Rename", "Yes" }, function(item_short) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will still populate r
in the prompt.
Could we do something like:
local prompt_input = prompt_select .. " y/n/R(ename): "
lib.prompt(prompt_input, prompt_select, { "", "y", "n" }, { "Yes", "No", "Rename", }, function(item_short)
utils.clear_prompt()
if item_short == "y" then
on_process()
elseif item_short == "" or item_short == "r" then
I might be overlooking some consideration here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anything that does not start with y or n shall become r in that case?
This feels wrong and having don't copy be the default case feels better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll update the lib.prompt to make the user prompt to lowercase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
anything that does not start with y or n shall become r in that case?
This feels wrong and having don't copy be the default case feels better
Yes please. Default n
is consistent and arguably better behaviour. All prompts default to no.
It's a somewhat breaking change however it is quite reasonable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently "r" is auto filled when a name conflict on copy occurs and I feel that is a better behaviour than defaulting to don't copy in that case.
The user needs to remove the r or update the autofilled character as it provides a second chance to cancel by cancelling in the rename prompt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently "r" is auto filled when a name conflict on copy occurs and I feel that is a better behaviour than defaulting to don't copy in that case.
I'm happy with r
as the default, however auto-filling is not consistent with other prompts. We can remove the auto-fill and rename can still be the default.
…m and telescope-select.nvim
Oops accidentally forced Push
I've noticed that my change makes the prompt ui from dressing.nvim or telescope-ui-select.nvim |
Thank you for testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please:
- resolve exception
- remove auto-fill r
local prompt_input = prompt_select .. " y/n/r(ename): " | ||
lib.prompt(prompt_input, prompt_select, { "y", "n", "r" }, { "Yes", "No", "Rename" }, function(item_short) | ||
local prompt_input = prompt_select .. " R(ename)/y/n: " | ||
lib.prompt(prompt_input, prompt_select, { "r", "y", "n" }, { "Rename", "Yes", "No" }, function(item_short) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On pressing escape:
E5108: Error executing lua: ...ite/pack/packer/start/mohamedarish/lua/nvim-tree/lib.lua:151: bad argument #1 to 'lower' (string expected, got nil)
stack traceback:
[C]: in function 'lower'
...ite/pack/packer/start/mohamedarish/lua/nvim-tree/lib.lua:151: in function 'on_confirm'
/usr/share/nvim/runtime/lua/vim/ui.lua:101: in function 'input'
...ite/pack/packer/start/mohamedarish/lua/nvim-tree/lib.lua:150: in function 'prompt'
...art/mohamedarish/lua/nvim-tree/actions/fs/copy-paste.lua:114: in function 'do_single_paste'
...art/mohamedarish/lua/nvim-tree/actions/fs/copy-paste.lua:187: in function 'f'
...ite/pack/packer/start/mohamedarish/lua/nvim-tree/api.lua:32: in function <...ite/pack/packer/start/mohamedarish/lua/nvim-tree/api.lua:30>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have fixed the exception and added another condition in the elseif block for rename for rename to be "r"/"R" or ""
local prompt_input = prompt_select .. " y/n/r(ename): " | ||
lib.prompt(prompt_input, prompt_select, { "y", "n", "r" }, { "Yes", "No", "Rename" }, function(item_short) | ||
local prompt_input = prompt_select .. " R(ename)/y/n: " | ||
lib.prompt(prompt_input, prompt_select, { "r", "y" }, { "Rename", "Yes" }, function(item_short) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently "r" is auto filled when a name conflict on copy occurs and I feel that is a better behaviour than defaulting to don't copy in that case.
I'm happy with r
as the default, however auto-filling is not consistent with other prompts. We can remove the auto-fill and rename can still be the default.
…so made rename to be blank or r.*/R.*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All cases tested OK.
Many thanks for your contribution.
fixes #2370.
Packer uses a bool flag comparing to check whether the given input is "y".
I've made it so that the default behaviour of the prompt is set to N for no (don't delete).
The default is set to R(ename) for name conflicts when copy-pasting.
Accidentally clicking enter/return after pressing d/bd should be made less common with this default behaviour.
the default behaviour is shown as a capital letter.