@fc-components/monaco-editor 0.1.25 → 0.1.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/monaco-editor.cjs.development.js +21 -3
- package/dist/monaco-editor.cjs.development.js.map +1 -1
- package/dist/monaco-editor.cjs.production.min.js +1 -1
- package/dist/monaco-editor.cjs.production.min.js.map +1 -1
- package/dist/monaco-editor.esm.js +21 -3
- package/dist/monaco-editor.esm.js.map +1 -1
- package/dist/promql/completion/situation.d.ts +1 -0
- package/package.json +1 -1
- package/src/promql/completion/getCompletionProvider.ts +15 -1
- package/src/promql/completion/situation.ts +8 -0
|
@@ -1386,6 +1386,10 @@ function resolveLabelMatcher(node, text, _pos) {
|
|
|
1386
1386
|
// - a StringNode (like in `{job="^"}`)
|
|
1387
1387
|
// - or an error node (like in `{job=^}`)
|
|
1388
1388
|
var inStringNode = !node.type.isError;
|
|
1389
|
+
// calculate where the value starts
|
|
1390
|
+
// for string nodes, it's after the opening quote
|
|
1391
|
+
// for error nodes, it's at the node start
|
|
1392
|
+
var valueStartPos = inStringNode ? node.from + 1 : node.from;
|
|
1389
1393
|
var parent = walk(node, [['parent', UnquotedLabelMatcher]]);
|
|
1390
1394
|
if (parent === null) {
|
|
1391
1395
|
return null;
|
|
@@ -1412,7 +1416,8 @@ function resolveLabelMatcher(node, text, _pos) {
|
|
|
1412
1416
|
type: 'IN_LABEL_SELECTOR_WITH_LABEL_NAME',
|
|
1413
1417
|
labelName: labelName,
|
|
1414
1418
|
betweenQuotes: inStringNode,
|
|
1415
|
-
otherLabels: otherLabels
|
|
1419
|
+
otherLabels: otherLabels,
|
|
1420
|
+
valueStartPos: valueStartPos
|
|
1416
1421
|
};
|
|
1417
1422
|
}
|
|
1418
1423
|
var metricName = getNodeText(metricNameNode, text);
|
|
@@ -1421,7 +1426,8 @@ function resolveLabelMatcher(node, text, _pos) {
|
|
|
1421
1426
|
metricName: metricName,
|
|
1422
1427
|
labelName: labelName,
|
|
1423
1428
|
betweenQuotes: inStringNode,
|
|
1424
|
-
otherLabels: otherLabels
|
|
1429
|
+
otherLabels: otherLabels,
|
|
1430
|
+
valueStartPos: valueStartPos
|
|
1425
1431
|
};
|
|
1426
1432
|
}
|
|
1427
1433
|
function resolveErrorInLabelMatcher(node, text, pos) {
|
|
@@ -1973,6 +1979,18 @@ function getCompletionProvider(monaco, dataProvider) {
|
|
|
1973
1979
|
// to stop it, we use a number-as-string sortkey,
|
|
1974
1980
|
// so that monaco keeps the order we use
|
|
1975
1981
|
var maxIndexDigits = items.length.toString().length;
|
|
1982
|
+
// Determine the completion range based on situation type
|
|
1983
|
+
var completionRange = range;
|
|
1984
|
+
if (situation && situation.type === 'IN_LABEL_SELECTOR_WITH_LABEL_NAME' && situation.betweenQuotes) {
|
|
1985
|
+
// For label values within quotes, replace from the start of the value to the current position
|
|
1986
|
+
var valueStartPosition = model.getPositionAt(situation.valueStartPos);
|
|
1987
|
+
completionRange = monaco.Range.lift({
|
|
1988
|
+
startLineNumber: valueStartPosition.lineNumber,
|
|
1989
|
+
endLineNumber: position.lineNumber,
|
|
1990
|
+
startColumn: valueStartPosition.column,
|
|
1991
|
+
endColumn: position.column
|
|
1992
|
+
});
|
|
1993
|
+
}
|
|
1976
1994
|
var suggestions = items.map(function (item, index) {
|
|
1977
1995
|
return {
|
|
1978
1996
|
kind: getMonacoCompletionItemKind(item.type, monaco),
|
|
@@ -1981,7 +1999,7 @@ function getCompletionProvider(monaco, dataProvider) {
|
|
|
1981
1999
|
detail: item.detail,
|
|
1982
2000
|
documentation: item.documentation,
|
|
1983
2001
|
sortText: index.toString().padStart(maxIndexDigits, '0'),
|
|
1984
|
-
range:
|
|
2002
|
+
range: completionRange,
|
|
1985
2003
|
command: item.triggerOnInsert ? {
|
|
1986
2004
|
id: 'editor.action.triggerSuggest',
|
|
1987
2005
|
title: ''
|