-
Notifications
You must be signed in to change notification settings - Fork 127
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
cmd.get_errorlevel
can break print
(same underlying issue as #93)
#134
Comments
I didn't think of this originally, but it actually seems only I tried replacing function test(rl_buffer)
rl_buffer:beginoutput()
os.execute('cmd /c echo test')
end Now So it seems the hooks somehow breaks |
clink.onbeginedit
and onendedit
not triggeringclink.onbeginedit
and onendedit
breaks print
It appears to be a side effect of CMD internally handles redirection in a way that is functionally reasonable, but which means the internal actual stdout handle can change whenever redirection is used. And since turning on The simplest workaround is print = clink.print but there are probably other things besides I originally made the fix for #93 run only once per session. But apparently the issue can recur again later on, so it looks like it will be necessary to repeatedly run the fix code. |
Great find -- thank you for reporting it! Also, thank you for clear descriptions, troubleshooting, and sharing the subtle observation that only |
clink.onbeginedit
and onendedit
breaks print
cmd.get_errorlevel
can break print
(same underlying issue as #93)
Thanks for the quick fix ❤️ I was looking at issues related to
Is this referring to a function's return value blocking another function, or is there some other case where the hooks are not called? Btw, I have some small feature requests/bug reports. Would you prefer I open a seperate issue for each or a single one explaining all of them? |
Both. The onendedit event does two things:
So, onendedit ends up not fully reliable as an "editing ended" indicator if a script needs to strictly know every time editing ends. I'm deferring exploring what to do about that, but I wanted to at least document that it isn't guaranteed to be called. Maybe I'll make the event happen each time, but make the stopping apply only to the part about replacing the input line?
I don't mind either way, but if they're separate they can be tracked/closed independently, and they can be searched independently by others. Depending on how related the issues are, it may or may not be useful to separate them. |
I'm going to split onendedit into two separate events:
That will be a breaking change, but it should be very rare that onendedit is being used to replace the edited line, so the impact should be minimal. |
This is what I was wondering. I understand that other functions can cancel the rest of the chain. But as long as clink itself doesnt do it, its good for me (and assume for most people). If the cancellation only happens because of user scripts, we can always make sure that the functions are registered in the correct order to produce expected behaviour.
I really havent use this tool enough to comment on this. I'm sure you know what you are doing :D |
Hi,
First of all, I would like thank you for maintaining this project. I knew of fancy terminal emulators like cmder/ConEmu, but never imagined an app that can accomplish so much by injecting into the native cmd. I've only been using this for a few days now, but I can already see this becoming one of those tools that I just cant live without.
Now, to the issue:
I was trying to use the
clink.onbeginedit
andonendedit
hooks as mentioned in #131. It initially worked well. But after a few commands, it spontaneously stops working. And when it does, other scripts seems to stop working as well. Here's my (test) script:and here's the settings:
I am running on the latest release 1.2.15 with a fresh profile. The issue can be reproduced in both normal cmd and Windows Terminal (Preview)
In the test above, you can see the hooks stopped working after 3 commands. Most of the time, it stays up for longer though. I just got lucky (or unlucky?) this time
Once the issue appears, when trying to reload, the prompt gets reloaded, but "start" was not printed and the hooks were not restored. Trying to run the "test" function afterwards also did not produce any output
Please let me know if any other information is needed. And thanks in advance for your time
The text was updated successfully, but these errors were encountered: