Fix search operation broken by search worker going away

Related commit:
- 23332400f5

Since the search worker can go away after its time-to-live
elapsed, we may need to pass again the haystack on which
search operations are performed.
This commit is contained in:
Raymond Hill 2020-08-02 12:46:52 -04:00
parent cff589637c
commit d654a5d6cf
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
2 changed files with 6 additions and 2 deletions

View File

@ -157,6 +157,10 @@ if (
}, { once: true }); }, { once: true });
}; };
const needHaystack = function() {
return worker instanceof Object === false;
};
const setHaystack = function(content) { const setHaystack = function(content) {
init(); init();
worker.postMessage({ what: 'setHaystack', content }); worker.postMessage({ what: 'setHaystack', content });
@ -183,7 +187,7 @@ if (
}); });
}; };
self.searchThread = { setHaystack, search, shutdown }; self.searchThread = { needHaystack, setHaystack, search, shutdown };
} }
/******************************************************************************/ /******************************************************************************/

View File

@ -286,7 +286,7 @@
} }
state.overlay = searchOverlay(state.query, queryCaseInsensitive(state.query)); state.overlay = searchOverlay(state.query, queryCaseInsensitive(state.query));
cm.addOverlay(state.overlay); cm.addOverlay(state.overlay);
if ( state.dirty ) { if ( state.dirty || self.searchThread.needHaystack() ) {
self.searchThread.setHaystack(cm.getValue()); self.searchThread.setHaystack(cm.getValue());
state.dirty = false; state.dirty = false;
} }