-
Notifications
You must be signed in to change notification settings - Fork 611
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
macOS search ('/') is not <Ctrl-C> cancellable #1347
Comments
Please see PR #1348 |
Thanks for you detailed report. By checking the existing PRs you could have found #1342 was already dealing with this issue. Fixing the remaining annoyances you mentioned will require quite some work to switch to the alternate readline interface and for a somehow limited benefit. |
Thanks for your kind response, @koutcher! So embarrasing! 🤦 I could've sworn I had fetched recently, but somehow I missed the commit from June 20. (Edit: Though checking ~/.bash_history, I did fetch and merge, so perhaps it just hadn't been pushed to GH yet... in any case, I'll check PRs more thoroughly next time) Thanks for all your hard work on this project, it contends with Vim as my favorite OSS project. Edit: I tested the June 20 commit and Completely unrelated: I have an extensive |
On macOS, when I start a search (using '/'), I cannot cancel out of it.
<Ctrl-C>
does nothing.It seems like the
readline
call ignoresSIGINT
.The only way I can return to the main view is to press
<Enter>
(and to run the search).kill -s 2 $(pgrep tig)
from another terminal window, and that will cancel the search.I do not experience this issue on Linux Mint MATE.
OS and
tig
versionsThe problem affects both Brew
tig
and my owntig
on macOS Sonoma 14.5:Here's my own build, using the latest commit (and the latest
readline
andncurses
from Brew):I do not see the problem on Linux Mint MATE
21.421.3, also running the latest commit, albeit not the samereadline
(though it's the latest fromapt
):(Limited) diagnosis
I am somewhat surprised that I didn't find an existing issue regarding this, but I looked.
<Ctrl-C>
to the terminal itself and to other apps, and<Ctrl-C>
works fromtig
main view.I also haven't debugged C code in eons, and I'm not that familiar with
readline
sources, but I tracked it down to theprompt.c
realine
call<Enter>
, and thesigint_absorb_handler
registered above it never gets called.Poking around some more, I fixed the problem by disabling these two lines:
Those two lines were introduced a while back, 2019-05-02: Piping to tig segfaults on exit #893 / ea43f8be22c7
My solution (or the best I could come up with), is to exclude those two lines on macOS builds (
#ifndef __APPLE__
). Though I'm not saying this is the best solution, just that it appears to work for me.I also glanced at the
readline
sources but didn't feel any more or less confident about the fix. There's also docs on the two functions in question:Re:
rl_prep_term_function
andrl_deprep_term_function
Re:
rl_prep_terminal
andrl_deprep_terminal
Furthermore, there are (only) 69 code hits on GitHub for
rl_prep_term_function = NULL;
:https://github.com/search?q=%22rl_prep_term_function+%3D+NULL%3B%22&type=code
though a lot of those hits are for the original
readline.c
, and fortig
forks. A few other hits do reference disabling those functions to avoid conflicting withncurses
, but those sources I looked at also disablereadline
signals (rl_catch_signals = 0
).Point being, nulling those functions doesn't seem very common.
Though I'm not a
readline
norncurses
expert by any means.Test results
I tested the error mentioned in #893, and it works for me:
I also ran
make test
on both my branch and the upstream branch, and I see the same results:make test
, and I didn't investigate further.Finally, while I only this afternoon made this branch, I'll continue to run it.
So far, it appears to work well, I can
<Ctrl-C>
to cancel search, search again,<Ctrl-C>
again, etc., and the prompt seems to behave well.The only oddity I've seen is if you press
<Esc>
during search, in interprets the next character as part of an escape sequence.E.g., if you start a search '/', type 'foo', then press
<Esc>
, thenb
, it moves the cursor back to the first column.Likewise,
<Esc>
thenw
deletes to the start of the line.This is similar to normal
tig
behavior, as far as I can tell, except when<Esc>
is followed by<Ctrl-C>
:On Brew
tig
, nothing happens; the next character you type is echoed to the search line.On Linux
tig
, after<Esc>
and<Ctrl-C>
, nothing happens until you press any key, and then the search is cancelled.<Ctrl-C>
again, thentig
itself exits.Using my branch on macOS is similar to Linux, but not exact:
After
<Esc>
and<Ctrl-C>
, a^C
is immediately echoed.Then it behaves like Linux: if you press
<Ctrl-C>
again,tig
exits; but if you press any other key, the search is cancelled and you return to the main view.(Really the only reason I ever hit
<Esc>
is when I cannot cancel search using<Ctrl-C>
, and then I mash<Esc>
out of frustration, hoping that'll work. But now the<Ctrl-C>
works, I'll probably stop hitting<Esc>
. Also because I now realizereadline
interprets it as the start of an escape sequence.)Given all that, I think my branch is an acceptable solution.
Though I'd feel better if another Mac user could vouch for the original issue.
Also if someone who knows
readline
more thoroughly could vouch for the proposed solution...Thanks for reading! A little in-depth, but I wanted to do a thorough diagnosis.
The text was updated successfully, but these errors were encountered: