-
Notifications
You must be signed in to change notification settings - Fork 89
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
Allow highlight to be interrupted by C-c #57
Comments
For some reason, the first time If an interruption of the only-once called To showcase the above, the below patch can be used to better see when stuff happens:
and then the control is returned to user, then try searching (
, also try interrupting a search via C-c, just as mentioned above and notice the output, then keep pressing C-c, even the in-
and you thus cannot quit diff --git a/search.c b/search.c
index 1761a6a..de4c137 100644
--- a/search.c
+++ b/search.c
@@ -999,9 +999,16 @@ hilite_line(linepos, line, line_len, chpos, sp, ep, cvt_ops)
* (currently POSIX, PCRE and V8-with-regexec2). }}
*/
searchp = line;
+ static int called=0;
+ called++;
+ FILE *f=fopen("/tmp/blah.log","a");
+ if (NULL == f) {
+ f=stderr;
+ }
+ fprintf(f, "called hilite_line (%d times thus far)\n",called); fflush(f);
do {
if (sp == NULL || ep == NULL)
- return;
+ goto ret;
create_hilites(linepos, sp-line, ep-line, chpos);
/*
* If we matched more than zero characters,
@@ -1014,8 +1021,19 @@ hilite_line(linepos, line, line_len, chpos, sp, ep, cvt_ops)
searchp++;
else /* end of line */
break;
+ if (ABORT_SIGS()) {
+ static int times=0;
+ times++;
+ fprintf(f,"interrupted (so far %d times)\n", times); fflush(f);
+ break;
+ }
} while (match_pattern(info_compiled(&search_info), search_info.text,
- searchp, line_end - searchp, &sp, &ep, 1, search_info.search_type));
+ searchp, line_end - searchp, &sp, &ep, 1, search_info.search_type));
+ret:
+ if (stderr != f) {
+ fclose(f);
+ sync();
+ }
}
#endif |
I have some ideas but I'd like to be able to reproduce this and haven't had much luck. I don't understand why you see so much CPU usage to highlight this file. On my aged MacBook, your time command shows much lower user space CPU usage:
What type of machine are you using? |
In the following run, try searching for
:
ie. type/:
(and press Enter), (I also pressedq
during the search, to show how many seconds it takes of 100% CPU aka 1 core, on my system)During the search for
:
in the above, pressingC-c
(akaCtrl+C
) doesn't stop the highlight operation.I naively tried to patch in this functionality but while it seems to work and breaks the operation, something keeps restarting it indefinitely and I'm thus forced to allow the high cpu usage to finish to regain any input control(unless ofc I
kill
theless
process):Thanks.
EDIT: To give an idea (of maybe)what's restarting it:
The text was updated successfully, but these errors were encountered: