Ported to CodeMirror 4. Reused code from HIDE(completion filtering, linting)