[ES|QL] fix query highlight when wrapped in multi-line#172080
Merged
dej611 merged 6 commits intoelastic:feature/esql-validationfrom Nov 29, 2023
Merged
[ES|QL] fix query highlight when wrapped in multi-line#172080dej611 merged 6 commits intoelastic:feature/esql-validationfrom
dej611 merged 6 commits intoelastic:feature/esql-validationfrom
Conversation
It needs a second check on ES side (I'll do it ASAP) but at a first look it seems safe |
23 tasks
💛 Build succeeded, but was flaky
Failed CI StepsMetrics [docs]
History
To update your PR or re-run it, just comment with: |
Contributor
|
Pinging @elastic/kibana-visualizations (Team:Visualizations) |
dej611
added a commit
that referenced
this pull request
Dec 7, 2023
## Summary Fixes #166242 , #166876, #166173 , part of #166092, #166084 List of tasks: * [x] AST work ( #166185 ) * [x] Basic validate work ( #166185 ) * [x] Hover feature ( #166185 ) * [x] Initial autocomplete work with new AST ( #166185 ) * Complete validation feature for MVP * [x] wildcards support ( #170014 ) * [x] remote index validation support ( #171996 ) * [x] wildcard support as `count` argument ( #172054 ) * [x] Aggressive caching for field queries: * cache as much as possible the `FROM` queries - possible clear the cache every 10/15 minutes? * do not fire a query when code == submitted code * cache as much as possible the custom `FROM` built from `ENRICH` policies - same clear policy as above * [x] Add unsupported fields warning messages * [x] Notify usage of `project` command with deprecation `warning` * Complete autocomplete work ( #171664 ) * [x] `stats` * [x] `where` * [x] `eval` * `math syntax` * [x] Aggressive cache for fields queries? ( #171866 ) * [x] Fix when cursor is not at the end position ( #172060 ) * [x] Revisit copy messages * Label Kibana-only messages * [x] Extend hover feature ( #171940 ) * [x] Disable editor query highlight for warnings ( #171968 ) * Fix editor highlight with new grammar * [x] on multi-line ( #172080 ) * [x] for functions ( #172287 ) ## Release notes Enhance ES|QL query editing experience with client side validation. Enhance ES|QL suggestions experience with more in context suggestions leveraging field and variable types. Show meta informations on ES|QL query hover on policy names. Show function signature on ES|QL query hover on function text. ### Checklist Delete any items that are not applicable to this PR. - [x] Any text added follows [EUI's writing guidelines](https://elastic.github.io/eui/#/guidelines/writing), uses sentence case text and includes [i18n support](https://github.com/elastic/kibana/blob/main/packages/kbn-i18n/README.md) - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios - [x] Any UI touched in this PR is usable by keyboard only (learn more about [keyboard accessibility](https://webaim.org/techniques/keyboard/)) --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: Stratoula Kalafateli <efstratia.kalafateli@elastic.co> Co-authored-by: Abdon Pijpelink <abdon.pijpelink@elastic.co>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR edits a bit the grammar to make the highlight work again.This PR fixes the highlight issue with the pipe wrapping in the editor.
The initial fix at grammar level didn't work, breaking some validation tests.
The new approach operates at the editor level, keeping track of the line number between each tokenize session and cleaning up the line from the initial
|for lines after the first one.Note that with this approach the initial
|remains "unstyled" for the language (it still inherit some styling from the editor) but that seems to still work with both themes.Note: It can become a problem if we decide to color the
|with a specific color in the future.TL;DR.
The edit is required due to how Monaco works in this case.
Long explanation
In the grammar the
UNKNOWN_CMDis a catch all place for all those strings who match a new line in a query/statement. Due to ES always receiving the query as single line they want to validate invalid strings with a catch all trick like that.ES|QL is defined to work as single line query language.
On the other hand Kibana uses Monaco which calls a
TokenProviderutility for each line, and each line is completely independent from each other. When the multi-line configuration is enabled with the wrapped, who puts the|at the beginning of each line (after the first one), the grammar replies that the|is not a known command and it cann handle anything else after worse. Removing theUNKNOWN_CMDfrom the grammar definition will make the hightlight work again as the|string is ignored.I've asked @luigidellaquila some insight about that specific token and if it was used in the ES codebase. From a quick investigation I did was just a superficial validation layer, not used anywhere else in the code.