Appending another transaction after processing an appendTransaction?

I’m working on a spellcheck plugin. I’ve defined a BEGIN meta attribute, which when seen runs a full-document spellcheck pass. For responsiveness reasons, I do not want to run a blocking check on the document while the user is editing the text with the plugin on. Instead I am appending a BEGIN transaction. However, when this appended transaction is applied, the outer apply loop treats it as already “seen”, and does will not append the other transactions that are normally created when I do a full pass.

In particular, I send updates to a control bar plugin via appendTransaction. Since my BEGIN does not trigger the plugin’s append, I do not get control updates while the user is editing. Is there any way to work around this behaviour?

Leave some trace in your plugin state? appendTransaction is designed to be able to observe any state change and react to it, once. I don’t entirely understand what you’re trying to do but it sounds like it may be a bad match for appendTransaction.

I’m not trying to react to the same state change more than once.

  • When tr.docChanged is true, my plugin’s apply method maps the ranges of the known misspellings.
  • The appendTransaction then emits a BEGIN transaction, which will trigger a full pass of the spellcheck in a future apply
  • After that future apply, I have a new state, which I’d like to emit a new appendTransaction for, but the applied transaction does not trigger appendTransaction.

I can, of course, do the whole step in a single apply, but the problem with that is that it means I am introducing a long-running (on the order of 100-200ms) process on a more or less per-keystroke basis, which you might be able to imagine makes the interface very laggy and unresponsive. Using appendTransaction to defer the long-running operation seems to resolve that issue.

My other option is to defer the long-running operation in some other way, perhaps by introducing async calls into my plugin, but that is a more complex solution than I’d like. I asked this question to find out if there’s a way around that. Sounds like there isn’t.