fix search highlight on doc change

This commit is contained in:
Chrissi2812 2019-05-28 13:51:37 +02:00
parent fc617a4d32
commit 753fc76324
No known key found for this signature in database
GPG Key ID: B4B82C7E618271DA

View File

@ -95,9 +95,15 @@ export default class Search extends Extension {
new Plugin({ new Plugin({
state: { state: {
init: (_, { doc }) => this.createDeco(doc), init: (_, { doc }) => this.createDeco(doc),
apply: (tr, old) => ( apply: (tr, old) => {
(tr.docChanged || this.options.searching) ? this.createDeco(tr.doc) : old if (this.options.searching) {
), return this.createDeco(tr.doc)
}
if (tr.docChanged) {
return old.map(tr.mapping, tr.doc)
}
return old
},
}, },
props: { props: {
decorations(state) { return this.getState(state) }, decorations(state) { return this.getState(state) },