Skip to content

codemirror: Fix initial pattern type not being recognized

Warren Gifford requested to merge fkling/34824-cm-search-input-patterntype into main

Created by: fkling

Fixes #34824 (closed)

The root issue was that the extensions get recreated due to changes higher up in the component tree. However, because the pattern type is set via a transaction the current value was lost and the extension default back to literal.

Order of events:

  1. Editor gets initialized
    1. Pattern type defaults to literal
  2. Transaction gets triggered (via hook) to set pattern type to regex
  3. Editor gets initialized`
    1. Pattern type defaults to literal

The hook that sets the pattern type via a transaction is not triggered again because its depdencies (editor instance, pattern type) didn't change.

The fix is to pass the current pattern type when initializing the extension.

I also looked over the code to see if there are other extension that would exhibit the same problem, but this one seems to be the only one.

https://user-images.githubusercontent.com/179026/166674916-765f19cf-35a1-4eb5-ab8b-0022feaf025c.mp4

Test plan

Opening the link in the issue correctly highlights the query and shows the correct hover information.

App preview:

Check out the client app preview documentation to learn more.

Merge request reports

Loading