Skip to content

fix(completion): use InsertAsSnippet for query language commands#416

Merged
Blankll merged 1 commit into
masterfrom
fix/query-command-snippet-completion
May 9, 2026
Merged

fix(completion): use InsertAsSnippet for query language commands#416
Blankll merged 1 commit into
masterfrom
fix/query-command-snippet-completion

Conversation

@Blankll
Copy link
Copy Markdown
Member

@Blankll Blankll commented May 8, 2026

Summary

  • Fix snippet placeholder ($0) leaking into query language command completions
  • Change insertTextRules from None to InsertAsSnippet for command keywords

Problem

When accepting completions for query language commands (ESQL, SQL, EQL, PPL) inside the query body field of _query, _sql, _eql/search, and _plugins/_ppl endpoints, the literal text $0 was inserted into the editor.

For example, completing WHERE produced WHERE $0 instead of WHERE with cursor positioned after it.

Root Cause

The command definitions use Monaco snippet placeholders in their insertText:

{ label: 'WHERE', insertText: 'WHERE $0', ... }

But the completion provider used InsertTextRule.None, which inserts text literally without interpreting snippet syntax.

Fix

Changed insertTextRules at completionProvider.ts:764:

- insertTextRules: monaco.languages.CompletionItemInsertTextRule.None,
+ insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,

This affects all four query languages: ESQL, SQL, EQL, and PPL.

Verification

  • ✅ ESLint clean
  • ✅ TypeScript type check clean
  • ✅ No other instances of this bug in the codebase (audited all insertTextRules usages)

Refers: #412

Query language commands (ESQL, SQL, EQL, PPL) use $0 snippet placeholders
in their insertText, but the completion provider was inserting them as
plain text (InsertTextRule.None). This caused literal $0 to appear in the
editor when accepting completions like WHERE, FROM, SELECT, etc.

Changed insertTextRules from None to InsertAsSnippet so Monaco correctly
interprets the snippet placeholders.

Fixes #412
@codecov
Copy link
Copy Markdown

codecov Bot commented May 8, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 64.68%. Comparing base (01307b8) to head (d8a6967).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #416   +/-   ##
=======================================
  Coverage   64.68%   64.68%           
=======================================
  Files          47       47           
  Lines        2308     2308           
  Branches      597      597           
=======================================
  Hits         1493     1493           
  Misses        698      698           
  Partials      117      117           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Blankll Blankll merged commit d0708ed into master May 9, 2026
6 checks passed
@Blankll Blankll deleted the fix/query-command-snippet-completion branch May 9, 2026 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant