@codingame/monaco-vscode-editor-api 3.2.2 → 4.0.0

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.
@@ -18,7 +18,7 @@ import { PLAINTEXT_LANGUAGE_ID, ModesRegistry } from 'vscode/vscode/vs/editor/co
18
18
  import { nullTokenize, nullTokenizeEncoded, NullState } from 'vscode/vscode/vs/editor/common/languages/nullTokenize';
19
19
  import { TextModelResolvedOptions, FindMatch } from 'vscode/vscode/vs/editor/common/model';
20
20
  import { IModelService } from 'vscode/vscode/vs/editor/common/services/model';
21
- import { AccessibilitySupport, ContentWidgetPositionPreference, CursorChangeReason, DefaultEndOfLine, EditorAutoIndentStrategy, EditorOption, EndOfLinePreference, EndOfLineSequence, MinimapPosition, MouseTargetType, OverlayWidgetPositionPreference, OverviewRulerLane, GlyphMarginLane, RenderLineNumbersType, RenderMinimap, ScrollbarVisibility, ScrollType, TextEditorCursorBlinkingStyle, TextEditorCursorStyle, TrackedRangeStickiness, WrappingIndent, InjectedTextCursorStops, PositionAffinity, ShowLightbulbIconMode, DocumentHighlightKind, CompletionItemKind, CompletionItemTag, CompletionItemInsertTextRule, SymbolKind, SymbolTag, IndentAction, CompletionTriggerKind, SignatureHelpTriggerKind, InlayHintKind, InlineCompletionTriggerKind, InlineEditTriggerKind, CodeActionTriggerType, NewSymbolNameTag } from 'vscode/vscode/vs/editor/common/standalone/standaloneEnums';
21
+ import { AccessibilitySupport, ContentWidgetPositionPreference, CursorChangeReason, DefaultEndOfLine, EditorAutoIndentStrategy, EditorOption, EndOfLinePreference, EndOfLineSequence, MinimapPosition, MinimapSectionHeaderStyle, MouseTargetType, OverlayWidgetPositionPreference, OverviewRulerLane, GlyphMarginLane, RenderLineNumbersType, RenderMinimap, ScrollbarVisibility, ScrollType, TextEditorCursorBlinkingStyle, TextEditorCursorStyle, TrackedRangeStickiness, WrappingIndent, InjectedTextCursorStops, PositionAffinity, ShowLightbulbIconMode, DocumentHighlightKind, CompletionItemKind, CompletionItemTag, CompletionItemInsertTextRule, SymbolKind, SymbolTag, IndentAction, CompletionTriggerKind, SignatureHelpTriggerKind, InlayHintKind, InlineCompletionTriggerKind, InlineEditTriggerKind, CodeActionTriggerType, NewSymbolNameTag, PartialAcceptTriggerKind } from 'vscode/vscode/vs/editor/common/standalone/standaloneEnums';
22
22
  import { createTrustedTypesPolicy } from 'vscode/vscode/vs/base/browser/trustedTypes';
23
23
  import { LineTokens } from 'vscode/vscode/vs/editor/common/tokens/lineTokens';
24
24
  import { renderViewLine2, RenderLineInput } from 'vscode/vscode/vs/editor/common/viewLayout/viewLineRenderer';
@@ -33,7 +33,7 @@ import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/cont
33
33
  import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding';
34
34
  import { IMarkerService } from 'vscode/vscode/vs/platform/markers/common/markers';
35
35
  import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener';
36
- import { MultiDiffEditorWidget } from 'vscode/vscode/vs/editor/browser/widget/multiDiffEditorWidget/multiDiffEditorWidget';
36
+ import { MultiDiffEditorWidget } from 'vscode/vscode/vs/editor/browser/widget/multiDiffEditor/multiDiffEditorWidget';
37
37
  import { Color } from 'vscode/vscode/vs/base/common/color';
38
38
  import { Range as Range$1 } from 'vscode/vscode/vs/editor/common/core/range';
39
39
  import { ILanguageFeaturesService } from 'vscode/vscode/vs/editor/common/services/languageFeatures';
@@ -109,6 +109,20 @@ function substituteMatches(lexer, str, id, matches, state) {
109
109
  return '';
110
110
  });
111
111
  }
112
+ function substituteMatchesRe(lexer, str, state) {
113
+ const re = /\$[sS](\d\d?)/g;
114
+ let stateMatches = null;
115
+ return str.replace(re, function (full, s) {
116
+ if (stateMatches === null) {
117
+ stateMatches = state.split('.');
118
+ stateMatches.unshift(state);
119
+ }
120
+ if (!empty(s) && s < stateMatches.length) {
121
+ return fixCase(lexer, stateMatches[s]);
122
+ }
123
+ return '';
124
+ });
125
+ }
112
126
  function findRules(lexer, inState) {
113
127
  let state = inState;
114
128
  while (state && state.length > 0) {
@@ -526,8 +540,8 @@ let MonarchTokenizer = MonarchTokenizer_1 = class MonarchTokenizer extends Dispo
526
540
  continue;
527
541
  }
528
542
  hasEmbeddedPopRule = true;
529
- let regex = rule.regex;
530
- const regexSource = rule.regex.source;
543
+ let regex = rule.resolveRegex(state.stack.state);
544
+ const regexSource = regex.source;
531
545
  if (regexSource.substr(0, 4) === '^(?:' && regexSource.substr(regexSource.length - 1, 1) === ')') {
532
546
  const flags = (regex.ignoreCase ? 'i' : '') + (regex.unicode ? 'u' : '');
533
547
  regex = ( new RegExp(regexSource.substr(4, regexSource.length - 5), flags));
@@ -609,7 +623,7 @@ let MonarchTokenizer = MonarchTokenizer_1 = class MonarchTokenizer extends Dispo
609
623
  const restOfLine = line.substr(pos);
610
624
  for (const rule of rules) {
611
625
  if (pos === 0 || !rule.matchOnlyAtLineStart) {
612
- matches = restOfLine.match(rule.regex);
626
+ matches = restOfLine.match(rule.resolveRegex(state));
613
627
  if (matches) {
614
628
  matched = matches[0];
615
629
  action = rule.action;
@@ -1290,6 +1304,7 @@ function createMonacoEditorAPI() {
1290
1304
  EndOfLinePreference: EndOfLinePreference,
1291
1305
  EndOfLineSequence: EndOfLineSequence,
1292
1306
  MinimapPosition: MinimapPosition,
1307
+ MinimapSectionHeaderStyle: MinimapSectionHeaderStyle,
1293
1308
  MouseTargetType: MouseTargetType,
1294
1309
  OverlayWidgetPositionPreference: OverlayWidgetPositionPreference,
1295
1310
  OverviewRulerLane: OverviewRulerLane,
@@ -1367,7 +1382,7 @@ function createKeywordMatcher(arr, caseInsensitive = false) {
1367
1382
  };
1368
1383
  }
1369
1384
  }
1370
- function compileRegExp(lexer, str) {
1385
+ function compileRegExp(lexer, str, handleSn) {
1371
1386
  str = str.replace(/@@/g, `\x01`);
1372
1387
  let n = 0;
1373
1388
  let hadExpansion;
@@ -1396,6 +1411,21 @@ function compileRegExp(lexer, str) {
1396
1411
  } while (hadExpansion && n < 5);
1397
1412
  str = str.replace(/\x01/g, '@');
1398
1413
  const flags = (lexer.ignoreCase ? 'i' : '') + (lexer.unicode ? 'u' : '');
1414
+ if (handleSn) {
1415
+ const match = str.match(/\$[sS](\d\d?)/g);
1416
+ if (match) {
1417
+ let lastState = null;
1418
+ let lastRegEx = null;
1419
+ return (state) => {
1420
+ if (lastRegEx && lastState === state) {
1421
+ return lastRegEx;
1422
+ }
1423
+ lastState = state;
1424
+ lastRegEx = ( new RegExp(substituteMatchesRe(lexer, str, state), flags));
1425
+ return lastRegEx;
1426
+ };
1427
+ }
1428
+ }
1399
1429
  return ( new RegExp(str, flags));
1400
1430
  }
1401
1431
  function selectScrutinee(id, matches, state, num) {
@@ -1462,12 +1492,12 @@ function createGuard(lexer, ruleName, tkey, val) {
1462
1492
  }
1463
1493
  else if (op === '~' || op === '!~') {
1464
1494
  if (pat.indexOf('$') < 0) {
1465
- const re = compileRegExp(lexer, '^' + pat + '$');
1495
+ const re = compileRegExp(lexer, '^' + pat + '$', false);
1466
1496
  tester = function (s) { return (op === '~' ? re.test(s) : !re.test(s)); };
1467
1497
  }
1468
1498
  else {
1469
1499
  tester = function (s, id, matches, state) {
1470
- const re = compileRegExp(lexer, '^' + substituteMatches(lexer, pat, id, matches, state) + '$');
1500
+ const re = compileRegExp(lexer, '^' + substituteMatches(lexer, pat, id, matches, state) + '$', false);
1471
1501
  return re.test(s);
1472
1502
  };
1473
1503
  }
@@ -1624,11 +1654,19 @@ class Rule {
1624
1654
  }
1625
1655
  this.matchOnlyAtLineStart = (sregex.length > 0 && sregex[0] === '^');
1626
1656
  this.name = this.name + ': ' + sregex;
1627
- this.regex = compileRegExp(lexer, '^(?:' + (this.matchOnlyAtLineStart ? sregex.substr(1) : sregex) + ')');
1657
+ this.regex = compileRegExp(lexer, '^(?:' + (this.matchOnlyAtLineStart ? sregex.substr(1) : sregex) + ')', true);
1628
1658
  }
1629
1659
  setAction(lexer, act) {
1630
1660
  this.action = compileAction(lexer, this.name, act);
1631
1661
  }
1662
+ resolveRegex(state) {
1663
+ if (this.regex instanceof RegExp) {
1664
+ return this.regex;
1665
+ }
1666
+ else {
1667
+ return this.regex(state);
1668
+ }
1669
+ }
1632
1670
  }
1633
1671
  function compile(languageId, json) {
1634
1672
  if (!json || typeof (json) !== 'object') {
@@ -2181,6 +2219,7 @@ function createMonacoLanguagesAPI() {
2181
2219
  InlineEditTriggerKind: InlineEditTriggerKind,
2182
2220
  CodeActionTriggerType: CodeActionTriggerType,
2183
2221
  NewSymbolNameTag: NewSymbolNameTag,
2222
+ PartialAcceptTriggerKind: PartialAcceptTriggerKind,
2184
2223
  FoldingRangeKind: FoldingRangeKind,
2185
2224
  SelectedSuggestionInfo: SelectedSuggestionInfo,
2186
2225
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-editor-api",
3
- "version": "3.2.2",
3
+ "version": "4.0.0",
4
4
  "keywords": [],
5
5
  "author": {
6
6
  "name": "CodinGame",
@@ -18,6 +18,6 @@
18
18
  "module": "esm/vs/editor/editor.api.js",
19
19
  "types": "esm/vs/editor/editor.api.d.ts",
20
20
  "dependencies": {
21
- "vscode": "npm:@codingame/monaco-vscode-api@3.2.2"
21
+ "vscode": "npm:@codingame/monaco-vscode-api@4.0.0"
22
22
  }
23
23
  }