Skip to content

search: Show token information for operators (CodeMirror)

Administrator requested to merge fkling/highlight-operators into main

Created by: fkling

Stacking on top of #38335, this commit extends the token info extension to highlight and show tooltip information for AND and OR operators.

To do this I updated the editor state to also compute a parse tree from the current query tokens in a new facet. If an operator is hovered I'm locating the corresponding node in the parse tree and use that nodes range information to highlight the operator and its operands.

If the query cannot be parsed as a parse tree it falls back to just highlighting the operator.

I guess highlighting operands in a different color would be even better but it's a start?

Also if you have a better idea for the tooltip text, please let me know!

Demo video:

https://user-images.githubusercontent.com/179026/177644906-ee659f41-3323-4067-8248-20d89048aee7.mp4

Test plan

Enter query containing and and or operators and parenthesis into query input and hover over operators.

App preview:

Check out the client app preview documentation to learn more.

Merge request reports

Loading