mirror of
https://github.com/SigNoz/signoz.git
synced 2025-12-22 18:06:35 +00:00
feat: handle multie select functions
This commit is contained in:
parent
f9c16b79d5
commit
b6f6a31ab5
@ -157,10 +157,21 @@ function QueryAggregationSelect(): JSX.Element {
|
|||||||
);
|
);
|
||||||
const lastOpenParen = currentText.lastIndexOf('(');
|
const lastOpenParen = currentText.lastIndexOf('(');
|
||||||
const endPos = view.state.selection.main.from;
|
const endPos = view.state.selection.main.from;
|
||||||
const startPos = lastOpenParen !== -1 ? lastOpenParen + 1 : endPos;
|
// Find the last comma before the cursor, but after the last open paren
|
||||||
|
const lastComma = currentText.lastIndexOf(',', endPos - 1);
|
||||||
|
const startPos =
|
||||||
|
lastComma > lastOpenParen ? lastComma + 1 : lastOpenParen + 1;
|
||||||
|
const before = view.state.sliceDoc(startPos, endPos).trim();
|
||||||
|
let insertText = '';
|
||||||
|
if (before.length > 0) {
|
||||||
|
// If there's already an argument, insert ", arg"
|
||||||
|
insertText = `, ${completion.label}`;
|
||||||
|
} else {
|
||||||
|
insertText = completion.label;
|
||||||
|
}
|
||||||
view.dispatch({
|
view.dispatch({
|
||||||
changes: { from: startPos, to: endPos, insert: completion.label },
|
changes: { from: endPos, insert: insertText },
|
||||||
selection: { anchor: startPos + completion.label.length },
|
selection: { anchor: endPos + insertText.length },
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user