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

[Bug] completions of git broken with colored-stats #208

Closed
pukkandan opened this issue Nov 25, 2021 · 12 comments
Closed

[Bug] completions of git broken with colored-stats #208

pukkandan opened this issue Nov 25, 2021 · 12 comments
Labels
bug Something isn't working

Comments

@pukkandan
Copy link

When setting colored-stats on in the inputrc, completions of the phrase git seems to be broken

Steps to reproduce:

  • Create a new clink profile with an .inputrc file containing just set colored-stats on
  • Open cmd and type git, then press Alt + = (possible-completions)

I get this output:

>git
argetmgit.exe       argetmgit-bash.exe  argetmgit-cmd.exe   argetmgit-gui.exe   argetmgitk.exe

All matches are getting prefixed with argetm. Weirdly enough, I could only reproduce this when the completion starts with git. Other completions like cmd work correctly

>cmd
cmd.exe          cmdiag.exe       cmdkey.exe       cmdl32.exe       cmd-startup.cmd

PS: In case it matters, I am using clink 1.2.46 portable on Windows 10 and can reproduce this issue with both Windows terminal and the normal cmd

Let me know if any additional details are needed

@pukkandan
Copy link
Author

I forgot to mention - the broken completions are not colored while the correct ones are

image

@chrisant996
Copy link
Owner

Please show the value of the LS_COLORS environment variable.

It sounds like there is a syntax error in its value.

@chrisant996 chrisant996 added the question Question about something label Nov 25, 2021
@pukkandan
Copy link
Author

This is happening even without defining any LS_COLORS. As I mentioned above, I am testing it with a fresh profile with just an inputrc containing set colored-stats on. But since you asked, I tried setting LS_COLORS to fi=37:di=33:ex=36, but that did not change anything. See the screenshot:

image

@chrisant996
Copy link
Owner

Can you please share your clink_settings file?

@pukkandan
Copy link
Author

It seems I am failing to make it clear. It is literally a completely fresh profile. I have only added an .inputrc. I haven't changed any settings

image

Here's the contents of clink.log in case it is usefull

187c start_logger              154 ---- 2021/11/26 01:06:56.068 -------------------------------------------------
187c start_logger              160 Host process is 'cmd.exe' (pid 6268)
187c start_logger              164 DLL path is 'D:\Programs\Terminal\clink'
187c start_logger              178 Windows version 10.0.19043 (x64)
187c start_logger              181 Clink version 1.2.46.69fc92 (x64)
187c hook_setter::hook_setter  156 >>> Started hook transaction.
187c hook_setter::attach_iat   313 Attempting to hook SetEnvironmentVariableW in IAT for module 00007FF7DD450000.
187c pe_info::iterate_imports  160 Found import in 'api-ms-win-core-processenvironment-l1-1-0.dll'
187c find_iat                  121 Found import at 00007FF7DD483860 (value is 00007FF9B89CC370).
187c hook_setter::attach_iat   313 Attempting to hook WriteConsoleW in IAT for module 00007FF7DD450000.
187c pe_info::iterate_imports  160 Found import in 'api-ms-win-core-console-l1-1-0.dll'
187c find_iat                  121 Found import at 00007FF7DD4834F8 (value is 00007FF9B89715C0).
187c hook_setter::attach_iat   313 Attempting to hook GetEnvironmentVariableW in IAT for module 00007FF7DD450000.
187c pe_info::iterate_imports  160 Found import in 'api-ms-win-core-processenvironment-l1-1-0.dll'
187c find_iat                  121 Found import at 00007FF7DD483880 (value is 00007FF9B898AB60).
187c hook_setter::commit       204 <<< Hook transaction committed.
187c hook_setter::hook_setter  156 >>> Started hook transaction.
187c hook_setter::detach_iat   356 Attempting to unhook 00007FF97E82ADF0 from GetEnvironmentVariableW in IAT for module 00007FF7DD450000.
187c pe_info::iterate_imports  160 Found import in 'api-ms-win-core-processenvironment-l1-1-0.dll'
187c find_iat                  121 Found import at 00007FF7DD483880 (value is 00007FF97E82ADF0).
187c hook_setter::commit       204 <<< Hook transaction committed.
187c hook_setter::hook_setter  156 >>> Started hook transaction.
187c hook_setter::attach_iat   313 Attempting to hook ReadConsoleW in IAT for module 00007FF7DD450000.
187c pe_info::iterate_imports  160 Found import in 'api-ms-win-core-console-l1-1-0.dll'
187c find_iat                  121 Found import at 00007FF7DD4834E0 (value is 00007FF9B8A5E4B0).
187c hook_setter::commit       204 <<< Hook transaction committed.
187c win_screen_buffer::begin  227 Using native terminal support; found 'WT_SESSION'.
187c load_user_inputrc        1373 Found Readline inputrc at 'D:\Programs\Terminal\clink\testprofile\.inputrc'
187c history_db::initialise   1268 master bank ctag: |CTAG_1637877287_942476546_8996_0
187c history_db::compact      1492 History:  0 active, 0 deleted
187c history_db::compact      1492 History:  0 active, 0 deleted
187c history_db::compact      1492 History:  0 active, 0 deleted
187c history_db::compact      1492 History:  0 active, 0 deleted

@pukkandan
Copy link
Author

Are you unable to reproduce this?

@chrisant996
Copy link
Owner

chrisant996 commented Nov 25, 2021

I am unable to reproduce this.

I am using a perfectly fresh profile, with an .inputrc file containing only set colored-stats on.
No history, no settings, LS_COLORS not set (so it uses the defaults).

The argetm you see is coming from ESC[targetm.
The default for ln in LS_COLORS is target, which means use the color of the target of the symlink.

I think your git*.exe files must all be symlinks.
And I've tried (today) many variations of having symlinks and even symlinks to symlinks.

I am unable to reproduce what you are experiencing.
It always looks up the target of the symlink, rather than using "target" as a color.

I believe that you're experiencing the issue. But there is something more going on than just "fresh profile", and it will be necessary to find what is missing before I'll be able to make any progress.

@chrisant996
Copy link
Owner

Aha. I found the place in the code that must be getting reached. I don't know how to make it get reached. There is something about your setup that is different from mine with respect to the installation of git for windows.

The issue here is a pre-existing bug in Readline. I can fix the bug, though I still don't know how it's being reached. There is some kind of context missing in the report -- by which I mean there is something neither of us realizes is important, and so neither of us knows to check it.

@chrisant996
Copy link
Owner

chrisant996 commented Nov 25, 2021

Found it:

You have a bunch of broken symlinks. All those "git*.exe" symlinks point to files that do not exist.

Readline fails to correctly show colors for broken symlinks when "target" color mode is used but no or (orphan) color is defined.

E.g. bash will have the same problem when configured the same (ln=target in LS_COLORS, but no or in LS_COLORS).

@pukkandan
Copy link
Author

pukkandan commented Nov 26, 2021

You are right that they are symlinks. I totally forgot about it coz I had it set up a while ago 🤦.

But they are not broken. The targets are valid and run correctly. However, their targets are not defined as absolute paths but as relative ones. Maybe that was the issue?

@pukkandan
Copy link
Author

pukkandan commented Nov 26, 2021

Can confirm that setting or in LS_COLORS does fix the issue (and shows git as orphaned). So likely just that ReadLine can't resolve symlinks with relative targets?

@chrisant996
Copy link
Owner

chrisant996 commented Nov 26, 2021

You are right that they are symlinks. I totally forgot about it coz I had it set up a while ago 🤦.

But they are not broken. The targets are valid and run correctly. However, their targets are not defined as absolute paths but as relative ones. Maybe that was the issue?

Aha, there was a second bug: os.globfiles() in Clink had a bug in how it was checking whether symlinks were orphaned. It ended up mistakenly thinking all symlinks are orphaned (unless the symlink is in the current directory -- which in all of my testing, they had been).

This was a nice couple of bugs -- one in Readline and one in Clink! Thanks for reporting this and helping me wrap my head around what was happening!

chrisant996 added a commit that referenced this issue Nov 26, 2021
`os.globfiles()` wasn't looking up symlinks correctly, and ended up
thinking all symlinks were orphaned.
@chrisant996 chrisant996 added bug Something isn't working and removed question Question about something labels Dec 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants