Skip to content
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

In 1.3.16.023688, screen height is detected incorrectly #281

Closed
garoto opened this issue Apr 28, 2022 · 8 comments
Closed

In 1.3.16.023688, screen height is detected incorrectly #281

garoto opened this issue Apr 28, 2022 · 8 comments
Labels
bug Something isn't working PRIORITY High priority

Comments

@garoto
Copy link

garoto commented Apr 28, 2022

Plus, not getting the --More-- prompt after a full-page of results with either completion-query-items and completion-auto-query-items anymore.

Was testing with the following as _inputrc:

set completion-auto-query-items                  on
#set completion-query-items			200

While toggling values on and off and incrementing/decrementing completion-query-items and restaring the plain cmd.exe window in between tests.

clink.log
06e8 start_logger              154 ---- 2022/04/28 11:32:17.709 -------------------------------------------------
06e8 start_logger              160 Host process is 'cmd.exe' (pid 1768)
06e8 start_logger              164 DLL path is 'C:\Apps\Diversos\Clink'
06e8 start_logger              178 Windows version 6.3.9600 (x64)
06e8 start_logger              181 Clink version 1.3.16.023688 (x64)
06e8 hook_setter::hook_setter  156 >>> Started hook transaction.
06e8 hook_setter::attach_iat   313 Attempting to hook SetEnvironmentVariableW in IAT for module 00007FF7473B0000.
06e8 pe_info::iterate_imports  159 Found import in 'api-ms-win-core-processenvironment-l1-2-0.dll'
06e8 find_iat                  121 Found import at 00007FF7473FF508 (value is 00007FFF1EA7CAD0).
06e8 hook_setter::attach_iat   313 Attempting to hook WriteConsoleW in IAT for module 00007FF7473B0000.
06e8 pe_info::iterate_imports  159 Found import in 'api-ms-win-core-console-l1-1-0.dll'
06e8 find_iat                  121 Found import at 00007FF7473FF388 (value is 00007FFF1EA856E0).
06e8 hook_setter::attach_iat   313 Attempting to hook GetEnvironmentVariableW in IAT for module 00007FF7473B0000.
06e8 pe_info::iterate_imports  159 Found import in 'api-ms-win-core-processenvironment-l1-2-0.dll'
06e8 find_iat                  121 Found import at 00007FF7473FF520 (value is 00007FFF1EA49070).
06e8 hook_setter::commit       204 <<< Hook transaction committed.
06e8 hook_setter::hook_setter  156 >>> Started hook transaction.
06e8 hook_setter::detach_iat   356 Attempting to unhook 00007FFEF516F5D0 from GetEnvironmentVariableW in IAT for module 00007FF7473B0000.
06e8 pe_info::iterate_imports  159 Found import in 'api-ms-win-core-processenvironment-l1-2-0.dll'
06e8 find_iat                  121 Found import at 00007FF7473FF520 (value is 00007FFEF516F5D0).
06e8 hook_setter::commit       204 <<< Hook transaction committed.
06e8 hook_setter::hook_setter  156 >>> Started hook transaction.
06e8 hook_setter::attach_iat   313 Attempting to hook ReadConsoleW in IAT for module 00007FF7473B0000.
06e8 pe_info::iterate_imports  159 Found import in 'api-ms-win-core-console-l1-1-0.dll'
06e8 find_iat                  121 Found import at 00007FF7473FF370 (value is 00007FFF1EB10840).
06e8 hook_setter::commit       204 <<< Hook transaction committed.
06e8 hook_setter::hook_setter  156 >>> Started hook transaction.
06e8 hook_setter::attach_iat   313 Attempting to hook SetConsoleTitleW in IAT for module 00007FF7473B0000.
06e8 pe_info::iterate_imports  159 Found import in 'api-ms-win-core-console-l2-1-0.dll'
06e8 find_iat                  121 Found import at 00007FF7473FF578 (value is 00007FFF1EA85830).
06e8 hook_setter::commit       204 <<< Hook transaction committed.
06e8 load_user_inputrc        1774 Found Readline inputrc at 'C:\Users\garoto\AppData\Local\clink\_inputrc'
06e8 host_lua::load_scripts    138 Loaded 1 Lua scripts in 0 ms
06e8 history_db::initialise   1245 master bank ctag: |CTAG_1651151416_151547921_3420_0
06e8 history_db::compact      1474 History:  10000 active, 75 deleted

Tell me if more details or troubleshooting are needed.

@chrisant996
Copy link
Owner

The --More-- prompt is unrelated to and unaffected by completion-auto-query-items or completion-query-items.

It is controlled by page-completions in the inputrc init file.

See Readline configuration variables.

The pager prompt (--More--) is displayed when there are more rows than can fit in one screen. If there are exactly as many and the command line prompt is multiple lines tall, then there won't be a pager prompt, and the new command line prompt may scroll some number of completions out of view.

Very little information has been shared, so I can't say more than that.

What is your clink set?
What steps did you follow?
What did happen?
How many possible completions were there?
What terminal program are you using?
What are the terminal width and height?

@chrisant996 chrisant996 added the needs more information The issue needs clarifying information label Apr 28, 2022
@chrisant996
Copy link
Owner

Also, I cannot reproduce "completion-auto-query-items on/off values are seemingly reversed". Everything cited in the title and description seem to be working properly for me.

Please elaborate on what you are seeing, what steps you're using, what your configuration is, etc.

@garoto
Copy link
Author

garoto commented Apr 28, 2022

Apparently, it has to do with a cmd.exe buffer height size. Anything greater than the "Window Height" value, will make the completion-auto-query-items to use that as actual screen size and dump as many completions as the buffer height (I counted heh).

This does not happen with v1.3.15.6e6e45, where buffer height size is ignored when filling the screeen with suggestions and the actual console line height is used instead.

screenshot-0738-28-04-2022

Playing with the value above to say 5000, will make my 1170 possible completions when Running from C:\Windows\System32 to be dumped all at once.

I'm testing with no user-set configuration at all right now, meaning no _inputrc or clink_settings, other than the two line _inputrc I tested above, but since completion-auto-query-items is set to on by default, I removed that file.

@chrisant996
Copy link
Owner

Apparently, it has to do with a cmd.exe buffer height size. Anything greater than the "Window Height" value, will make the completion-auto-query-items to use that as actual screen size and dump as many completions as the buffer height (I counted heh).

Aha! Good work, yes, I can confirm that. Thanks for finding the repro steps and the crucial detail!

In Windows Terminal it always works correctly, but that's because Windows Terminal (intentionally) broke the console APIs, and the scrollback buffer height is hidden from console programs.

The cause is a bug in 7bc131e (a change which fixed #262). It correctly uses the entire console width, but it needs to use the window height instead of the console height (the latter includes the entire scrollback buffer).

@chrisant996 chrisant996 added bug Something isn't working PRIORITY High priority and removed needs more information The issue needs clarifying information labels Apr 28, 2022
@chrisant996 chrisant996 changed the title In 1.3.16.023688, "completion-auto-query-items" on/off values are seemingly reversed In 1.3.16.023688, screen height is detected incorrectly Apr 28, 2022
@chrisant996
Copy link
Owner

v1.3.17 is published, with the fix.

@garoto
Copy link
Author

garoto commented Apr 28, 2022

*phew* so glad you were able to figure it out with my shitty reproduction scenario, I was running out of options regarding troubleshooting this.

On a related note, how does completion-query-items differs from completion-auto-query-items? Aren't both options kinda overlapping each other?

v1.3.17 is working fine btw, thank you.

@chrisant996
Copy link
Owner

On a related note, how does completion-query-items differs from completion-auto-query-items? Aren't both options kinda overlapping each other?

They're related, yes.

completion-query-items is a prompt threshold based on the total number of possible completions.

Since it's completions -- not rows of completions -- it can be a bit clumsy depending on the terminal width.

completion-auto-query-items is a prompt threshold based on whether the rows of completions will exceed the terminal window height (when added with the current input line height).

Basically the latter is "prompt if the possible matches will end up scrolling".

@garoto
Copy link
Author

garoto commented Apr 28, 2022

I think I understand both options better now, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working PRIORITY High priority
Projects
None yet
Development

No branches or pull requests

2 participants
-