Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ES|QL] Make sure that the commands are not overwritten #204711

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -612,22 +612,30 @@ async function getExpressionSuggestionsByType(
(fragment) => Boolean(getColumnByName(fragment, references)),
(_fragment: string, rangeToReplace?: { start: number; end: number }) => {
// COMMAND fie<suggest>
return fieldSuggestions.map((suggestion) => ({
...suggestion,
text: suggestion.text + (['grok', 'dissect'].includes(command.name) ? ' ' : ''),
command: TRIGGER_SUGGESTION_COMMAND,
rangeToReplace,
}));
return fieldSuggestions.map((suggestion) => {
// if there is already a command, we don't want to override it
if (suggestion.command) return suggestion;
return {
...suggestion,
text: suggestion.text + (['grok', 'dissect'].includes(command.name) ? ' ' : ''),
command: TRIGGER_SUGGESTION_COMMAND,
rangeToReplace,
};
});
},
(fragment: string, rangeToReplace: { start: number; end: number }) => {
// COMMAND field<suggest>
if (['grok', 'dissect'].includes(command.name)) {
return fieldSuggestions.map((suggestion) => ({
...suggestion,
text: suggestion.text + ' ',
command: TRIGGER_SUGGESTION_COMMAND,
rangeToReplace,
}));
return fieldSuggestions.map((suggestion) => {
// if there is already a command, we don't want to override it
if (suggestion.command) return suggestion;
return {
...suggestion,
text: suggestion.text + ' ',
command: TRIGGER_SUGGESTION_COMMAND,
rangeToReplace,
};
});
}

const finalSuggestions = [{ ...pipeCompleteItem, text: ' | ' }];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,16 @@ export async function suggest(
(fragment) => columnExists(fragment),
(_fragment: string, rangeToReplace?: { start: number; end: number }) => {
// KEEP fie<suggest>
return fieldSuggestions.map((suggestion) => ({
...suggestion,
text: suggestion.text,
command: TRIGGER_SUGGESTION_COMMAND,
rangeToReplace,
}));
return fieldSuggestions.map((suggestion) => {
// if there is already a command, we don't want to override it
if (suggestion.command) return suggestion;
return {
...suggestion,
text: suggestion.text,
command: TRIGGER_SUGGESTION_COMMAND,
rangeToReplace,
};
});
},
(fragment: string, rangeToReplace: { start: number; end: number }) => {
// KEEP field<suggest>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,16 @@ export async function suggest(
(fragment) => columnExists(fragment),
(_fragment: string, rangeToReplace?: { start: number; end: number }) => {
// KEEP fie<suggest>
return fieldSuggestions.map((suggestion) => ({
...suggestion,
text: suggestion.text,
command: TRIGGER_SUGGESTION_COMMAND,
rangeToReplace,
}));
return fieldSuggestions.map((suggestion) => {
// if there is already a command, we don't want to override it
if (suggestion.command) return suggestion;
return {
...suggestion,
text: suggestion.text,
command: TRIGGER_SUGGESTION_COMMAND,
rangeToReplace,
};
});
},
(fragment: string, rangeToReplace: { start: number; end: number }) => {
// KEEP field<suggest>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,15 @@ export async function suggest(
// SORT fie<suggest>
return [
...pushItUpInTheList(
fieldSuggestions.map((suggestion) => ({
...suggestion,
command: TRIGGER_SUGGESTION_COMMAND,
rangeToReplace,
})),
fieldSuggestions.map((suggestion) => {
// if there is already a command, we don't want to override it
if (suggestion.command) return suggestion;
return {
...suggestion,
command: TRIGGER_SUGGESTION_COMMAND,
rangeToReplace,
};
}),
true
),
...functionSuggestions,
Expand Down
Loading