mirror of https://github.com/gorhill/uBlock.git
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:
parent
cff589637c
commit
d654a5d6cf
|
@ -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 };
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue