@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.
@@ -1392,6 +1392,10 @@ function resolveLabelMatcher(node, text, _pos) {
1392
1392
  // - a StringNode (like in `{job="^"}`)
1393
1393
  // - or an error node (like in `{job=^}`)
1394
1394
  var inStringNode = !node.type.isError;
1395
+ // calculate where the value starts
1396
+ // for string nodes, it's after the opening quote
1397
+ // for error nodes, it's at the node start
1398
+ var valueStartPos = inStringNode ? node.from + 1 : node.from;
1395
1399
  var parent = walk(node, [['parent', lezerMetricsql.UnquotedLabelMatcher]]);
1396
1400
  if (parent === null) {
1397
1401
  return null;
@@ -1418,7 +1422,8 @@ function resolveLabelMatcher(node, text, _pos) {
1418
1422
  type: 'IN_LABEL_SELECTOR_WITH_LABEL_NAME',
1419
1423
  labelName: labelName,
1420
1424
  betweenQuotes: inStringNode,
1421
- otherLabels: otherLabels
1425
+ otherLabels: otherLabels,
1426
+ valueStartPos: valueStartPos
1422
1427
  };
1423
1428
  }
1424
1429
  var metricName = getNodeText(metricNameNode, text);
@@ -1427,7 +1432,8 @@ function resolveLabelMatcher(node, text, _pos) {
1427
1432
  metricName: metricName,
1428
1433
  labelName: labelName,
1429
1434
  betweenQuotes: inStringNode,
1430
- otherLabels: otherLabels
1435
+ otherLabels: otherLabels,
1436
+ valueStartPos: valueStartPos
1431
1437
  };
1432
1438
  }
1433
1439
  function resolveErrorInLabelMatcher(node, text, pos) {
@@ -1979,6 +1985,18 @@ function getCompletionProvider(monaco, dataProvider) {
1979
1985
  // to stop it, we use a number-as-string sortkey,
1980
1986
  // so that monaco keeps the order we use
1981
1987
  var maxIndexDigits = items.length.toString().length;
1988
+ // Determine the completion range based on situation type
1989
+ var completionRange = range;
1990
+ if (situation && situation.type === 'IN_LABEL_SELECTOR_WITH_LABEL_NAME' && situation.betweenQuotes) {
1991
+ // For label values within quotes, replace from the start of the value to the current position
1992
+ var valueStartPosition = model.getPositionAt(situation.valueStartPos);
1993
+ completionRange = monaco.Range.lift({
1994
+ startLineNumber: valueStartPosition.lineNumber,
1995
+ endLineNumber: position.lineNumber,
1996
+ startColumn: valueStartPosition.column,
1997
+ endColumn: position.column
1998
+ });
1999
+ }
1982
2000
  var suggestions = items.map(function (item, index) {
1983
2001
  return {
1984
2002
  kind: getMonacoCompletionItemKind(item.type, monaco),
@@ -1987,7 +2005,7 @@ function getCompletionProvider(monaco, dataProvider) {
1987
2005
  detail: item.detail,
1988
2006
  documentation: item.documentation,
1989
2007
  sortText: index.toString().padStart(maxIndexDigits, '0'),
1990
- range: range,
2008
+ range: completionRange,
1991
2009
  command: item.triggerOnInsert ? {
1992
2010
  id: 'editor.action.triggerSuggest',
1993
2011
  title: ''