-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Add --paging-full-mode option to commandline to determine if paging is complete #8485
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
Add --paging-full-mode option to commandline to determine if paging is complete #8485
Conversation
I don't understand why you want to use a binding like that. That said, it seems fine to add this. |
src/pager.h
Outdated
@@ -186,6 +186,7 @@ class pager_t { | |||
bool is_navigating_contents() const; | |||
|
|||
// Become fully disclosed. | |||
bool get_fully_disclosed() const; |
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 would be more consistent with others
bool get_fully_disclosed() const; | |
bool is_fully_disclosed() const; |
also the comment is off now, can you move the new method in a separate paragraph like the other methods above?
@@ -239,6 +241,10 @@ maybe_t<int> builtin_commandline(parser_t &parser, io_streams_t &streams, const | |||
paging_mode = true; | |||
break; | |||
} | |||
case 'F': { | |||
paging_full_mode = true; |
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.
you forgot to update the check for incompatible options
at src/builtins/commandline.cpp:332
@@ -167,6 +168,7 @@ maybe_t<int> builtin_commandline(parser_t &parser, io_streams_t &streams, const | |||
{L"line", no_argument, nullptr, 'L'}, | |||
{L"search-mode", no_argument, nullptr, 'S'}, | |||
{L"paging-mode", no_argument, nullptr, 'P'}, | |||
{L"paging-full-mode", no_argument, nullptr, 'F'}, |
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 considered giving the existing -P/--paging-mode
an optional argument, like --paging-mode=full
, but that would work slightly worse with interactive completions, so yours seems fine.
Maybe just remove the short option, since it's not so obvious? It's okay to keep it if you like.
LGTM, please fix the issues krobelus identified and I'll merge. Thank you. |
Rely on remaining_to_disclose count rather than fully_disclosed flag to determine if all completions are shown (allows consistent behavior between short and long completion lists)
Thanks for the feedback, it helped me realize that my initial implementation was not exactly what I wanted. I would like to avoid the slightly inconsistent behavior of the TAB key depending on the length of the completion list: short (fits within PAGER_UNDISCLOSED_MAX_ROWS) or long. A double press on TAB will start cycling through completions when the list is short and show a full (filling the screen) list of completions when the list is long (a third TAB press would start cycling through completions). Since I don't mind losing the ability to cycle through possibly long lists of completions using TAB, I would rather have TAB stop interacting with the completion list once it is fully shown (in other words, I would like to disable TAB if the next TAB press will start cycling through completions). The previous version worked only for long lists. This version relies on the Combined with the following binding:
I get the desired behavior. Please let me know if this is an acceptable approach. Thanks again for the guidance. |
That all makes sense, merged with some minor changes in ceade16 |
Description
Trying to prevent the TAB key from cycling through completions, I found this question
(https://unix.stackexchange.com/questions/565196/fish-shell-disable-pager-navigation-through-tab-shift-tab) offering a way to disable TAB when in pager mode (using
bind \t 'if not commandline -P; commandline -f complete; end'
).However, I would like to have the following functionality:
PAGER_UNDISCLOSED_MAX_ROWS
)bind \t 'if not commandline -P; commandline -f complete; end'
)I can achieve this by exposing the pager's
full_disclosed
flag and storing it in thecommandline_state_t
structure. I added an option tocommandline
(-F
) to return thisfully_disclosed
flag and use the following for my TAB keybinding:bind \t 'if not commandline -F; commandline -f complete; end'
which seems to achieve what I was looking for, without, as far as I can tell, breaking anything else.
Is there any interest in merging this change? Is my approach acceptable?
Thanks in advance for the guidance.
TODOs: