For my searches, I usually have "List all occurrences" checked, which is great so that all search results are listed in the bottom window.
But sometimes I have a really huge log file in the editor (current one is 1 GB). If I don't forget to uncheck the "List all occurrences", then SE will freeze on me for a long time, and I have no way of aborting - I need to wait it out.
It would be a nice improvement if the user could abort this search.
Hmm... There is an interesting performance issue with the _find_all() function. It doesn't check if it is searching through a huge file and always calls _SetAllOldLineNumbers(). While the _SetAllOldLineNumbers() feature is nice to have (it handles next/prev through the list where lines are deleted). It is NOT worth it if you have a huge file. Your entire file will end up being spilled to disk (ouch!) because it's modifying all line flags.
I added a test if the file size is too large for setting all old line numbers. I also added some code to assist in cancelling the search. It won't help you if the search string isn't found but that should be quick as long as you have an SSD.
(v18 only) Here's the code for a better _find_all() function for tbfind.e:
static int _find_all(_str search_text = '', _str search_options = '', boolean addBookmark = false, boolean listAll = false, SearchResults* results = null)
{
if (search_text:=='') {
return 0;
}
int num_bookmarks = 0;
int num_matches = 0;
int last_line = -1;
if (listAll && p_buf_size<def_use_fundamental_mode_ksize) {
_SetAllOldLineNumbers();
}
typeless p; save_pos(p);
boolean search_mark = (pos('m', search_options, 1, 'I') != 0);
if (search_mark) {
_begin_select(); _begin_line();
} else {
top();
}
int status = search(search_text, 'xv,@'search_options'<+');
if (!status) {
// Check every .5 seconds
typeless start_time=_time('b');
while (!status) {
if (addBookmark && (last_line != p_RLine)) {
if (num_bookmarks > def_find_high_added_bookmarks) {
int result = _message_box("Adding a large number bookmarks to this buffer. Continue adding bookmarks?", "", MB_YESNOCANCEL|MB_ICONQUESTION);
if (result == IDCANCEL) {
break;
} else if (result == IDNO) {
addBookmark = false;
}
}
if (addBookmark) {
if (isEclipsePlugin()) {
set_bookmark("Bookmark: '"get_bookmark_name()"'");
} else{
set_bookmark('-r 'get_bookmark_name(), true);
}
last_line = p_RLine;
++num_bookmarks;
}
}
if (listAll && results != null) {
results->insertCurrentMatch();
}
++num_matches;
typeless end_time=_time('b');
if (end_time-start_time>500) { // More than .5 seconds
start_time=end_time;
if( _IsKeyPending(false)) {
int orig_def_actapp=def_actapp;
def_actapp=0;
save_search(auto s1,auto s2,auto s3,auto s4,auto s5);
flush_keyboard();
int result1=_message_box('Would you like to cancel listing all occurences?','',MB_YESNOCANCEL);
restore_search(s1,s2,s3,s4,s5);
def_actapp=orig_def_actapp;
if (result1!=IDNO) {
break;
}
}
}
_MaybeUnhideLine();
status = repeat_search();
}
}
restore_pos(p);
return(num_matches);
}