@uiw/react-codemirror 4.25.2 → 4.25.4

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/README.md CHANGED
@@ -1,38 +1,41 @@
1
1
  <div markdown="1">
2
2
  <sup>Using <a href="https://wangchujiang.com/#/app" target="_blank">my app</a> is also a way to <a href="https://wangchujiang.com/#/sponsor" target="_blank">support</a> me:</sup>
3
3
  <br>
4
- <a target="_blank" href="https://apps.apple.com/app/VidCrop/6752624705" title="VidCrop for macOS"><img align="center" alt="VidCrop" height="52" width="52" src="https://github.com/user-attachments/assets/91d2b281-271a-4107-9ef6-f3b11bd6dbac"></a>
5
- <a target="_blank" href="https://apps.apple.com/app/Vidwall/6747587746" title="Vidwall for macOS"><img align="center" alt="Vidwall" height="52" width="52" src="https://github.com/user-attachments/assets/7b5df70a-ed91-4d4b-85be-f00e60a09ce9"></a>
6
- <a target="_blank" href="https://wangchujiang.com/mousio-hint/" title="Mousio Hint for macOS"><img align="center" alt="Mousio Hint" height="52" width="52" src="https://github.com/user-attachments/assets/3c0af128-0cef-44e5-a8db-4741dc5a6690"></a>
7
- <a target="_blank" href="https://apps.apple.com/app/6746747327" title="Mousio for macOS"><img align="center" alt="Mousio" height="52" width="52" src="https://github.com/user-attachments/assets/9edf61ff-5a6c-4676-9cc2-8fd3c1ad0dfb"></a>
8
- <a target="_blank" href="https://apps.apple.com/app/6745227444" title="Musicer for macOS"><img align="center" alt="Musicer" height="52" width="52" src="https://github.com/user-attachments/assets/b7abfba8-88ff-4c86-a125-43073d5aef22"></a>
9
- <a target="_blank" href="https://apps.apple.com/app/6743841447" title="Audioer for macOS"><img align="center" alt="Audioer" height="52" width="52" src="https://github.com/user-attachments/assets/7a836865-8c90-4119-87bc-19e06a76c957"></a>
10
- <a target="_blank" href="https://apps.apple.com/app/6744690194" title="FileSentinel for macOS"><img align="center" alt="FileSentinel" height="52" width="52" src="https://github.com/user-attachments/assets/28bce2cc-290e-45bf-9068-585ff6ecafe9"></a>
11
- <a target="_blank" href="https://apps.apple.com/app/6743495172" title="FocusCursor for macOS"><img align="center" alt="FocusCursor" height="52" width="52" src="https://github.com/user-attachments/assets/d543668a-737b-4853-a6bb-eaa269e69836"></a>
12
- <a target="_blank" href="https://apps.apple.com/app/6742680573" title="Videoer for macOS"><img align="center" alt="Videoer" height="52" width="52" src="https://github.com/user-attachments/assets/10ffb0f1-0625-40d6-93f1-2c2496592595"></a>
13
- <a target="_blank" href="https://apps.apple.com/app/6740425504" title="KeyClicker for macOS"><img align="center" alt="KeyClicker" height="52" width="52" src="https://github.com/user-attachments/assets/5a19fcb9-cb81-4855-b4ea-31c604d9612a"></a>
14
- <a target="_blank" href="https://apps.apple.com/app/6739052447" title="DayBar for macOS"><img align="center" alt="DayBar" height="52" width="52" src="https://github.com/user-attachments/assets/771b608d-594c-492d-8532-d9231e383f5b"></a>
15
- <a target="_blank" href="https://apps.apple.com/app/6739444407" title="Iconed for macOS"><img align="center" alt="Iconed" height="52" width="52" src="https://github.com/user-attachments/assets/8a35dc7b-4faf-4e2a-9311-f66d6844a896"></a>
16
- <a target="_blank" href="https://apps.apple.com/app/6737160756" title="RightMenu Master for macOS"><img align="center" alt="RightMenu Master" height="52" width="52" src="https://github.com/user-attachments/assets/39a76541-71bf-4de7-a01c-c62f0557dff5"></a>
17
- <a target="_blank" href="https://apps.apple.com/app/6723903021" title="Paste Quick for macOS"><img align="center" alt="Quick RSS" height="52" width="52" src="https://github.com/user-attachments/assets/bdaad5b7-9810-44ce-8f17-8410864465d2"></a>
18
- <a target="_blank" href="https://apps.apple.com/app/6670696072" title="Quick RSS for macOS/iOS"><img align="center" alt="Quick RSS" height="52" width="52" src="https://github.com/user-attachments/assets/374106b5-a448-4d1d-9ccb-b04b6bc681ed"></a>
19
- <a target="_blank" href="https://apps.apple.com/app/6670167443" title="Web Serve for macOS"><img align="center" alt="Web Serve" height="52" width="52" src="https://github.com/user-attachments/assets/e1d9f76f-0f3d-4ba5-8a15-253ee173bb1c"></a>
20
- <a target="_blank" href="https://apps.apple.com/app/6503953628" title="Copybook Generator for macOS/iOS"><img align="center" alt="Copybook Generator" height="52" width="52" src="https://github.com/jaywcjlove/jaywcjlove/assets/1680273/b90e42ff-158b-4534-82ca-5898fd0e8d73"></a>
21
- <a target="_blank" href="https://apps.apple.com/app/6471227008" title="DevTutor for macOS/iOS"><img align="center" alt="DevTutor for SwiftUI" height="52" width="52" src="https://github.com/jaywcjlove/jaywcjlove/assets/1680273/f15c154d-0192-48eb-8e0e-9e245ffd974a"></a>
22
- <a target="_blank" href="https://apps.apple.com/app/6479819388" title="RegexMate for macOS/iOS"><img align="center" alt="RegexMate" height="52" width="52" src="https://github.com/jaywcjlove/jaywcjlove/assets/1680273/aabe5aa9-9a96-4390-8bed-c3e4023d0dea"></a>
23
- <a target="_blank" href="https://apps.apple.com/app/6479194014" title="Time Passage for macOS/iOS"><img align="center" alt="Time Passage" height="52" width="52" src="https://github.com/jaywcjlove/time-passage/assets/1680273/6f30e429-e6f3-4dbe-9921-a5effe2a05e9"></a>
24
- <a target="_blank" href="https://apps.apple.com/app/6478772538" title="IconizeFolder for macOS"><img align="center" alt="Iconize Folder" height="52" width="52" src="https://github.com/jaywcjlove/jaywcjlove/assets/1680273/fa9d8b9c-1e51-4ded-877c-fa5b21c47220"></a>
25
- <a target="_blank" href="https://apps.apple.com/app/6478511402" title="Textsound Saver for macOS/iOS"><img align="center" alt="Textsound Saver" height="52" width="52" src="https://github.com/jaywcjlove/jaywcjlove/assets/1680273/0595e842-980b-4574-8891-a8ba853a08be"></a>
26
- <a target="_blank" href="https://apps.apple.com/app/6476924627" title="Create Custom Symbols for macOS"><img align="center" alt="Create Custom Symbols" height="52" width="52" src="https://github.com/jaywcjlove/jaywcjlove/assets/1680273/8cd022ce-a3f1-4e89-b7c6-6fbd0d4db77c"></a>
27
- <a target="_blank" href="https://apps.apple.com/app/6476452351" title="DevHub for macOS"><img align="center" alt="DevHub" height="52" width="52" src="https://github.com/user-attachments/assets/4a44a4fd-67ce-430b-af0a-72f18feaa47d"></a>
28
- <a target="_blank" href="https://apps.apple.com/app/6476400184" title="Resume Revise for macOS"><img align="center" alt="Resume Revise" height="52" width="52" src="https://github.com/jaywcjlove/jaywcjlove/assets/1680273/c9954a20-1905-48de-bdf8-d71837974aa2"></a>
29
- <a target="_blank" href="https://apps.apple.com/app/6472593276" title="Palette Genius for macOS"><img align="center" alt="Palette Genius" height="52" width="52" src="https://github.com/jaywcjlove/jaywcjlove/assets/1680273/27340413-d355-45b2-8f6f-6ac37682d957"></a>
30
- <a target="_blank" href="https://apps.apple.com/app/6470879005" title="Symbol Scribe for macOS"><img align="center" alt="Symbol Scribe" height="52" width="52" src="https://github.com/jaywcjlove/jaywcjlove/assets/1680273/c7249f05-fa70-4def-a1e9-571d5f171fc9"></a>
4
+ <a target="_blank" href="https://apps.apple.com/app/Deskmark/6755948110" title="Deskmark for macOS"><img alt="Deskmark" height="52" width="52" src="https://wangchujiang.com/appicon/deskmark.png"></a>
5
+ <a target="_blank" href="https://apps.apple.com/app/Keyzer/6500434773" title="Keyzer for macOS"><img alt="Keyzer" height="52" width="52" src="https://wangchujiang.com/appicon/keyzer.png"></a>
6
+ <a target="_blank" href="https://github.com/jaywcjlove/vidwall-hub" title="Vidwall Hub for macOS"><img alt="Vidwall Hub" height="52" width="52" src="https://wangchujiang.com/appicon/vidwall-hub.png"></a>
7
+ <a target="_blank" href="https://apps.apple.com/app/VidCrop/6752624705" title="VidCrop for macOS"><img alt="VidCrop" height="52" width="52" src="https://wangchujiang.com/appicon/vidcrop.png"></a>
8
+ <a target="_blank" href="https://apps.apple.com/app/Vidwall/6747587746" title="Vidwall for macOS"><img alt="Vidwall" height="52" width="52" src="https://wangchujiang.com/appicon/vidwall.png"></a>
9
+ <a target="_blank" href="https://wangchujiang.com/mousio-hint/" title="Mousio Hint for macOS"><img alt="Mousio Hint" height="52" width="52" src="https://wangchujiang.com/appicon/mousio-hint.png"></a>
10
+ <a target="_blank" href="https://apps.apple.com/app/6746747327" title="Mousio for macOS"><img alt="Mousio" height="52" width="52" src="https://wangchujiang.com/appicon/mousio.png"></a>
11
+ <a target="_blank" href="https://apps.apple.com/app/6745227444" title="Musicer for macOS"><img alt="Musicer" height="52" width="52" src="https://wangchujiang.com/appicon/musicer.png"></a>
12
+ <a target="_blank" href="https://apps.apple.com/app/6743841447" title="Audioer for macOS"><img alt="Audioer" height="52" width="52" src="https://wangchujiang.com/appicon/audioer.png"></a>
13
+ <a target="_blank" href="https://apps.apple.com/app/6744690194" title="FileSentinel for macOS"><img alt="FileSentinel" height="52" width="52" src="https://wangchujiang.com/appicon/file-sentinel.png"></a>
14
+ <a target="_blank" href="https://apps.apple.com/app/6743495172" title="FocusCursor for macOS"><img alt="FocusCursor" height="52" width="52" src="https://wangchujiang.com/appicon/focus-cursor.png"></a>
15
+ <a target="_blank" href="https://apps.apple.com/app/6742680573" title="Videoer for macOS"><img alt="Videoer" height="52" width="52" src="https://wangchujiang.com/appicon/videoer.png"></a>
16
+ <a target="_blank" href="https://apps.apple.com/app/6740425504" title="KeyClicker for macOS"><img alt="KeyClicker" height="52" width="52" src="https://wangchujiang.com/appicon/key-clicker.png"></a>
17
+ <a target="_blank" href="https://apps.apple.com/app/6739052447" title="DayBar for macOS"><img alt="DayBar" height="52" width="52" src="https://wangchujiang.com/appicon/daybar.png"></a>
18
+ <a target="_blank" href="https://apps.apple.com/app/6739444407" title="Iconed for macOS"><img alt="Iconed" height="52" width="52" src="https://wangchujiang.com/appicon/iconed.png"></a>
19
+ <a target="_blank" href="https://apps.apple.com/app/6737160756" title="Mousio for macOS"><img alt="Mousio" height="52" width="52" src="https://wangchujiang.com/appicon/rightmenu-master.png"></a>
20
+ <a target="_blank" href="https://apps.apple.com/app/6723903021" title="Paste Quick for macOS"><img alt="Quick RSS" height="52" width="52" src="https://wangchujiang.com/appicon/paste-quick.png"></a>
21
+ <a target="_blank" href="https://apps.apple.com/app/6670696072" title="Quick RSS for macOS/iOS"><img alt="Quick RSS" height="52" width="52" src="https://wangchujiang.com/appicon/quick-rss.png"></a>
22
+ <a target="_blank" href="https://apps.apple.com/app/6670167443" title="Web Serve for macOS"><img alt="Web Serve" height="52" width="52" src="https://wangchujiang.com/appicon/web-serve.png"></a>
23
+ <a target="_blank" href="https://apps.apple.com/app/6503953628" title="Copybook Generator for macOS/iOS"><img alt="Copybook Generator" height="52" width="52" src="https://wangchujiang.com/appicon/copybook-generator.png"></a>
24
+ <a target="_blank" href="https://apps.apple.com/app/6471227008" title="DevTutor for macOS/iOS"><img alt="DevTutor for SwiftUI" height="52" width="52" src="https://wangchujiang.com/appicon/devtutor.png"></a>
25
+ <a target="_blank" href="https://apps.apple.com/app/6479819388" title="RegexMate for macOS/iOS"><img alt="RegexMate" height="52" width="52" src="https://wangchujiang.com/appicon/regex-mate.png"></a>
26
+ <a target="_blank" href="https://apps.apple.com/app/6479194014" title="Time Passage for macOS/iOS"><img alt="Time Passage" height="52" width="52" src="https://wangchujiang.com/appicon/time-passage.png"></a>
27
+ <a target="_blank" href="https://apps.apple.com/app/6478772538" title="IconizeFolder for macOS"><img alt="Iconize Folder" height="52" width="52" src="https://wangchujiang.com/appicon/iconize-folder.png"></a>
28
+ <a target="_blank" href="https://apps.apple.com/app/6478511402" title="Textsound Saver for macOS/iOS"><img alt="Textsound Saver" height="52" width="52" src="https://wangchujiang.com/appicon/textsound-saver.png"></a>
29
+ <a target="_blank" href="https://apps.apple.com/app/6476924627" title="Create Custom Symbols for macOS"><img alt="Create Custom Symbols" height="52" width="52" src="https://wangchujiang.com/appicon/create-custom-symbols.png"></a>
30
+ <a target="_blank" href="https://apps.apple.com/app/6476452351" title="DevHub for macOS"><img alt="DevHub" height="52" width="52" src="https://wangchujiang.com/appicon/devhub.png"></a>
31
+ <a target="_blank" href="https://apps.apple.com/app/6476400184" title="Resume Revise for macOS"><img alt="Resume Revise" height="52" width="52" src="https://wangchujiang.com/appicon/resume-revise.png"></a>
32
+ <a target="_blank" href="https://apps.apple.com/app/6472593276" title="Palette Genius for macOS"><img alt="Palette Genius" height="52" width="52" src="https://wangchujiang.com/appicon/palette-genius.png"></a>
33
+ <a target="_blank" href="https://apps.apple.com/app/6470879005" title="Symbol Scribe for macOS"><img alt="Symbol Scribe" height="52" width="52" src="https://wangchujiang.com/appicon/symbol-scribe.png"></a>
31
34
  <br><br>
32
35
  </div>
33
36
  <hr>
34
37
 
35
- <p align="center">
38
+ <p>
36
39
  <a href="https://uiwjs.github.io/react-codemirror/">
37
40
  <img alt="react-codemirror logo" src="https://user-images.githubusercontent.com/1680273/177491470-c31a6d7e-f676-4914-a027-2fbeebfeb5b4.svg">
38
41
  </a>
@@ -237,7 +237,7 @@ must be quoted as JSON strings.
237
237
  For example:
238
238
 
239
239
  ```javascript
240
- parser.withProps(
240
+ parser.configure({props: [
241
241
  styleTags({
242
242
  // Style Number and BigNumber nodes
243
243
  "Number BigNumber": tags.number,
@@ -252,7 +252,7 @@ parser.withProps(
252
252
  // Style the node named "/" as punctuation
253
253
  '"/"': tags.punctuation
254
254
  })
255
- )
255
+ ]})
256
256
  ```
257
257
  */
258
258
  function styleTags(spec) {
@@ -294,7 +294,30 @@ function styleTags(spec) {
294
294
  }
295
295
  return ruleNodeProp.add(byName);
296
296
  }
297
- const ruleNodeProp = new dist/* NodeProp */.uY();
297
+ const ruleNodeProp = new dist/* NodeProp */.uY({
298
+ combine(a, b) {
299
+ let cur, root, take;
300
+ while (a || b) {
301
+ if (!a || b && a.depth >= b.depth) {
302
+ take = b;
303
+ b = b.next;
304
+ }
305
+ else {
306
+ take = a;
307
+ a = a.next;
308
+ }
309
+ if (cur && cur.mode == take.mode && !take.context && !cur.context)
310
+ continue;
311
+ let copy = new Rule(take.tags, take.mode, take.context);
312
+ if (cur)
313
+ cur.next = copy;
314
+ else
315
+ root = copy;
316
+ cur = copy;
317
+ }
318
+ return root;
319
+ }
320
+ });
298
321
  class Rule {
299
322
  constructor(tags, mode, context, next) {
300
323
  this.tags = tags;
@@ -3867,6 +3890,7 @@ class NodeProp {
3867
3890
  this.deserialize = config.deserialize || (() => {
3868
3891
  throw new Error("This node type doesn't define a deserialize function");
3869
3892
  });
3893
+ this.combine = config.combine || null;
3870
3894
  }
3871
3895
  /**
3872
3896
  This is meant to be used with
@@ -4131,7 +4155,10 @@ class NodeSet {
4131
4155
  if (add) {
4132
4156
  if (!newProps)
4133
4157
  newProps = Object.assign({}, type.props);
4134
- newProps[add[0].id] = add[1];
4158
+ let value = add[1], prop = add[0];
4159
+ if (prop.combine && prop.id in newProps)
4160
+ value = prop.combine(newProps[prop.id], value);
4161
+ newProps[prop.id] = value;
4135
4162
  }
4136
4163
  }
4137
4164
  newTypes.push(newProps ? new NodeType(type.name, newProps, type.id, type.flags) : type);
@@ -4604,6 +4631,7 @@ class TreeNode extends BaseNode {
4604
4631
  get lastChild() { return this.nextChild(this._tree.children.length - 1, -1, 0, 4 /* Side.DontCare */); }
4605
4632
  childAfter(pos) { return this.nextChild(0, 1, pos, 2 /* Side.After */); }
4606
4633
  childBefore(pos) { return this.nextChild(this._tree.children.length - 1, -1, pos, -2 /* Side.Before */); }
4634
+ prop(prop) { return this._tree.prop(prop); }
4607
4635
  enter(pos, side, mode = 0) {
4608
4636
  let mounted;
4609
4637
  if (!(mode & IterMode.IgnoreOverlays) && (mounted = MountedTree.get(this._tree)) && mounted.overlay) {
@@ -4697,6 +4725,7 @@ class BufferNode extends BaseNode {
4697
4725
  get lastChild() { return this.child(-1, 0, 4 /* Side.DontCare */); }
4698
4726
  childAfter(pos) { return this.child(1, pos, 2 /* Side.After */); }
4699
4727
  childBefore(pos) { return this.child(-1, pos, -2 /* Side.Before */); }
4728
+ prop(prop) { return this.type.prop(prop); }
4700
4729
  enter(pos, side, mode = 0) {
4701
4730
  if (mode & IterMode.ExcludeBuffers)
4702
4731
  return null;
@@ -5114,7 +5143,7 @@ function buildTree(data) {
5114
5143
  function takeNode(parentStart, minPos, children, positions, inRepeat, depth) {
5115
5144
  let { id, start, end, size } = cursor;
5116
5145
  let lookAheadAtStart = lookAhead, contextAtStart = contextHash;
5117
- while (size < 0) {
5146
+ if (size < 0) {
5118
5147
  cursor.next();
5119
5148
  if (size == -1 /* SpecialRecord.Reuse */) {
5120
5149
  let node = reused[id];
@@ -5278,7 +5307,7 @@ function buildTree(data) {
5278
5307
  fork.next();
5279
5308
  while (fork.pos > startPos) {
5280
5309
  if (fork.size < 0) {
5281
- if (fork.size == -3 /* SpecialRecord.ContextChange */)
5310
+ if (fork.size == -3 /* SpecialRecord.ContextChange */ || fork.size == -4 /* SpecialRecord.LookAhead */)
5282
5311
  localSkipped += 4;
5283
5312
  else
5284
5313
  break scan;
@@ -5719,8 +5748,15 @@ class MixedParse {
5719
5748
  }
5720
5749
  else if (!cursor.type.isAnonymous && (nest = this.nest(cursor, this.input)) &&
5721
5750
  (cursor.from < cursor.to || !nest.overlay)) {
5722
- if (!cursor.tree)
5751
+ if (!cursor.tree) {
5723
5752
  materialize(cursor);
5753
+ // materialize create one more level of nesting
5754
+ // we need to add depth to active overlay for going backwards
5755
+ if (overlay)
5756
+ overlay.depth++;
5757
+ if (covered)
5758
+ covered.depth++;
5759
+ }
5724
5760
  let oldMounts = fragmentCursor.findMounts(cursor.from, nest.parser);
5725
5761
  if (typeof nest.overlay == "function") {
5726
5762
  overlay = new ActiveOverlay(nest.parser, nest.overlay, oldMounts, this.inner.length, cursor.from, cursor.tree, overlay);
@@ -7999,7 +8035,7 @@ const completionConfig = /*@__PURE__*/state_.Facet.define({
7999
8035
  addToOptions: [],
8000
8036
  positionInfo: defaultPositionInfo,
8001
8037
  filterStrict: false,
8002
- compareCompletions: (a, b) => a.label.localeCompare(b.label),
8038
+ compareCompletions: (a, b) => (a.sortText || a.label).localeCompare(b.sortText || b.label),
8003
8039
  interactionDelay: 75,
8004
8040
  updateSyncTime: 100
8005
8041
  }, {
@@ -8198,7 +8234,8 @@ class CompletionTooltip {
8198
8234
  this.range = rangeAroundSelected(open.options.length, open.selected, this.view.state.facet(completionConfig).maxRenderedOptions);
8199
8235
  this.showOptions(open.options, cState.id);
8200
8236
  }
8201
- if (this.updateSelectedOption(open.selected)) {
8237
+ let newSel = this.updateSelectedOption(open.selected);
8238
+ if (newSel) {
8202
8239
  this.destroyInfo();
8203
8240
  let { completion } = open.options[open.selected];
8204
8241
  let { info } = completion;
@@ -8215,6 +8252,7 @@ class CompletionTooltip {
8215
8252
  }
8216
8253
  else {
8217
8254
  this.addInfoPane(infoResult, completion);
8255
+ newSel.setAttribute("aria-describedby", this.info.id);
8218
8256
  }
8219
8257
  }
8220
8258
  }
@@ -8222,6 +8260,7 @@ class CompletionTooltip {
8222
8260
  this.destroyInfo();
8223
8261
  let wrap = this.info = document.createElement("div");
8224
8262
  wrap.className = "cm-tooltip cm-completionInfo";
8263
+ wrap.id = "cm-completionInfo-" + Math.floor(Math.random() * 0xffff).toString(16);
8225
8264
  if (content.nodeType != null) {
8226
8265
  wrap.appendChild(content);
8227
8266
  this.infoDestroy = null;
@@ -8247,8 +8286,10 @@ class CompletionTooltip {
8247
8286
  }
8248
8287
  }
8249
8288
  else {
8250
- if (opt.hasAttribute("aria-selected"))
8289
+ if (opt.hasAttribute("aria-selected")) {
8251
8290
  opt.removeAttribute("aria-selected");
8291
+ opt.removeAttribute("aria-describedby");
8292
+ }
8252
8293
  }
8253
8294
  }
8254
8295
  if (set)
@@ -8362,7 +8403,7 @@ function score(option) {
8362
8403
  }
8363
8404
  function sortOptions(active, state) {
8364
8405
  let options = [];
8365
- let sections = null;
8406
+ let sections = null, dynamicSectionScore = null;
8366
8407
  let addOption = (option) => {
8367
8408
  options.push(option);
8368
8409
  let { section } = option.completion;
@@ -8389,13 +8430,24 @@ function sortOptions(active, state) {
8389
8430
  for (let option of a.result.options)
8390
8431
  if (match = matcher.match(option.label)) {
8391
8432
  let matched = !option.displayLabel ? match.matched : getMatch ? getMatch(option, match.matched) : [];
8392
- addOption(new Option(option, a.source, matched, match.score + (option.boost || 0)));
8433
+ let score = match.score + (option.boost || 0);
8434
+ addOption(new Option(option, a.source, matched, score));
8435
+ if (typeof option.section == "object" && option.section.rank === "dynamic") {
8436
+ let { name } = option.section;
8437
+ if (!dynamicSectionScore)
8438
+ dynamicSectionScore = Object.create(null);
8439
+ dynamicSectionScore[name] = Math.max(score, dynamicSectionScore[name] || -1e9);
8440
+ }
8393
8441
  }
8394
8442
  }
8395
8443
  }
8396
8444
  if (sections) {
8397
8445
  let sectionOrder = Object.create(null), pos = 0;
8398
- let cmp = (a, b) => { var _a, _b; return ((_a = a.rank) !== null && _a !== void 0 ? _a : 1e9) - ((_b = b.rank) !== null && _b !== void 0 ? _b : 1e9) || (a.name < b.name ? -1 : 1); };
8446
+ let cmp = (a, b) => {
8447
+ return (a.rank === "dynamic" && b.rank === "dynamic" ? dynamicSectionScore[b.name] - dynamicSectionScore[a.name] : 0) ||
8448
+ (typeof a.rank == "number" ? a.rank : 1e9) - (typeof b.rank == "number" ? b.rank : 1e9) ||
8449
+ (a.name < b.name ? -1 : 1);
8450
+ };
8399
8451
  for (let s of sections.sort(cmp)) {
8400
8452
  pos -= 1e5;
8401
8453
  sectionOrder[s.name] = pos;
@@ -9727,6 +9779,7 @@ class LintState {
9727
9779
  diagnostics = diagnosticFilter(diagnostics, state);
9728
9780
  let sorted = diagnostics.slice().sort((a, b) => a.from - b.from || a.to - b.to);
9729
9781
  let deco = new state_.RangeSetBuilder(), active = [], pos = 0;
9782
+ let scan = state.doc.iter(), scanPos = 0, docLen = state.doc.length;
9730
9783
  for (let i = 0;;) {
9731
9784
  let next = i == sorted.length ? null : sorted[i];
9732
9785
  if (!next && !active.length)
@@ -9738,6 +9791,8 @@ class LintState {
9738
9791
  }
9739
9792
  else {
9740
9793
  from = next.from;
9794
+ if (from > docLen)
9795
+ break;
9741
9796
  to = next.to;
9742
9797
  active.push(next);
9743
9798
  i++;
@@ -9754,8 +9809,31 @@ class LintState {
9754
9809
  break;
9755
9810
  }
9756
9811
  }
9812
+ to = Math.min(to, docLen);
9813
+ let widget = false;
9814
+ if (active.some(d => d.from == from && (d.to == to || to == docLen))) {
9815
+ widget = from == to;
9816
+ if (!widget && to - from < 10) {
9817
+ let behind = from - (scanPos + scan.value.length);
9818
+ if (behind > 0) {
9819
+ scan.next(behind);
9820
+ scanPos = from;
9821
+ }
9822
+ for (let check = from;;) {
9823
+ if (check >= to) {
9824
+ widget = true;
9825
+ break;
9826
+ }
9827
+ if (!scan.lineBreak && scanPos + scan.value.length > check)
9828
+ break;
9829
+ check = scanPos + scan.value.length;
9830
+ scanPos += scan.value.length;
9831
+ scan.next();
9832
+ }
9833
+ }
9834
+ }
9757
9835
  let sev = maxSeverity(active);
9758
- if (active.some(d => d.from == d.to || (d.from == d.to - 1 && state.doc.lineAt(d.from).to == d.from))) {
9836
+ if (widget) {
9759
9837
  deco.add(from, from, view_.Decoration.widget({
9760
9838
  widget: new DiagnosticWidget(sev),
9761
9839
  diagnostics: active.slice()
@@ -9770,6 +9848,8 @@ class LintState {
9770
9848
  }));
9771
9849
  }
9772
9850
  pos = to;
9851
+ if (pos == docLen)
9852
+ break;
9773
9853
  for (let i = 0; i < active.length; i++)
9774
9854
  if (active[i].to <= pos)
9775
9855
  active.splice(i--, 1);
@@ -10022,22 +10102,36 @@ function batchResults(promises, sink, error) {
10022
10102
  }
10023
10103
  const lintConfig = /*@__PURE__*/state_.Facet.define({
10024
10104
  combine(input) {
10025
- return Object.assign({ sources: input.map(i => i.source).filter(x => x != null) }, (0,state_.combineConfig)(input.map(i => i.config), {
10026
- delay: 750,
10027
- markerFilter: null,
10028
- tooltipFilter: null,
10029
- needsRefresh: null,
10030
- hideOn: () => null,
10031
- }, {
10032
- needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u)
10033
- }));
10105
+ return {
10106
+ sources: input.map(i => i.source).filter(x => x != null),
10107
+ ...(0,state_.combineConfig)(input.map(i => i.config), {
10108
+ delay: 750,
10109
+ markerFilter: null,
10110
+ tooltipFilter: null,
10111
+ needsRefresh: null,
10112
+ hideOn: () => null,
10113
+ }, {
10114
+ delay: Math.max,
10115
+ markerFilter: combineFilter,
10116
+ tooltipFilter: combineFilter,
10117
+ needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u),
10118
+ hideOn: (a, b) => !a ? b : !b ? a : (t, x, y) => a(t, x, y) || b(t, x, y),
10119
+ autoPanel: (a, b) => a || b
10120
+ })
10121
+ };
10034
10122
  }
10035
10123
  });
10124
+ function combineFilter(a, b) {
10125
+ return !a ? b : !b ? a : (d, s) => b(a(d, s), s);
10126
+ }
10036
10127
  /**
10037
10128
  Given a diagnostic source, this function returns an extension that
10038
10129
  enables linting with that source. It will be called whenever the
10039
- editor is idle (after its content changed). If `null` is given as
10040
- source, this only configures the lint extension.
10130
+ editor is idle (after its content changed).
10131
+
10132
+ Note that settings given here will apply to all linters active in
10133
+ the editor. If `null` is given as source, this only configures the
10134
+ lint extension.
10041
10135
  */
10042
10136
  function linter(source, config = {}) {
10043
10137
  return [
@@ -10087,9 +10181,10 @@ function renderDiagnostic(view, diagnostic, inPanel) {
10087
10181
  let nameElt = keyIndex < 0 ? name : [name.slice(0, keyIndex),
10088
10182
  crelt("u", name.slice(keyIndex, keyIndex + 1)),
10089
10183
  name.slice(keyIndex + 1)];
10184
+ let markClass = action.markClass ? " " + action.markClass : "";
10090
10185
  return crelt("button", {
10091
10186
  type: "button",
10092
- class: "cm-diagnosticAction",
10187
+ class: "cm-diagnosticAction" + markClass,
10093
10188
  onclick: click,
10094
10189
  onmousedown: click,
10095
10190
  "aria-label": ` Action: ${name}${keyIndex < 0 ? "" : ` (access key "${keys[i]})"`}.`
@@ -10512,7 +10607,7 @@ const lintGutterTooltip = /*@__PURE__*/state_.StateField.define({
10512
10607
  create() { return null; },
10513
10608
  update(tooltip, tr) {
10514
10609
  if (tooltip && tr.docChanged)
10515
- tooltip = hideTooltip(tr, tooltip) ? null : Object.assign(Object.assign({}, tooltip), { pos: tr.changes.mapPos(tooltip.pos) });
10610
+ tooltip = hideTooltip(tr, tooltip) ? null : { ...tooltip, pos: tr.changes.mapPos(tooltip.pos) };
10516
10611
  return tr.effects.reduce((t, e) => e.is(setLintGutterTooltip) ? e.value : t, tooltip);
10517
10612
  },
10518
10613
  provide: field => view_.showTooltip.from(field)
@@ -10742,7 +10837,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__708__;
10742
10837
  /* harmony export */ cL: () => (/* binding */ historyKeymap),
10743
10838
  /* harmony export */ pw: () => (/* binding */ defaultKeymap)
10744
10839
  /* harmony export */ });
10745
- /* unused harmony exports blockComment, blockUncomment, copyLineDown, copyLineUp, cursorCharBackward, cursorCharBackwardLogical, cursorCharForward, cursorCharForwardLogical, cursorCharLeft, cursorCharRight, cursorDocEnd, cursorDocStart, cursorGroupBackward, cursorGroupForward, cursorGroupForwardWin, cursorGroupLeft, cursorGroupRight, cursorLineBoundaryBackward, cursorLineBoundaryForward, cursorLineBoundaryLeft, cursorLineBoundaryRight, cursorLineDown, cursorLineEnd, cursorLineStart, cursorLineUp, cursorMatchingBracket, cursorPageDown, cursorPageUp, cursorSubwordBackward, cursorSubwordForward, cursorSyntaxLeft, cursorSyntaxRight, deleteCharBackward, deleteCharBackwardStrict, deleteCharForward, deleteGroupBackward, deleteGroupForward, deleteLine, deleteLineBoundaryBackward, deleteLineBoundaryForward, deleteToLineEnd, deleteToLineStart, deleteTrailingWhitespace, emacsStyleKeymap, historyField, indentLess, indentMore, indentSelection, insertBlankLine, insertNewline, insertNewlineAndIndent, insertNewlineKeepIndent, insertTab, invertedEffects, isolateHistory, lineComment, lineUncomment, moveLineDown, moveLineUp, redo, redoDepth, redoSelection, selectAll, selectCharBackward, selectCharBackwardLogical, selectCharForward, selectCharForwardLogical, selectCharLeft, selectCharRight, selectDocEnd, selectDocStart, selectGroupBackward, selectGroupForward, selectGroupForwardWin, selectGroupLeft, selectGroupRight, selectLine, selectLineBoundaryBackward, selectLineBoundaryForward, selectLineBoundaryLeft, selectLineBoundaryRight, selectLineDown, selectLineEnd, selectLineStart, selectLineUp, selectMatchingBracket, selectPageDown, selectPageUp, selectParentSyntax, selectSubwordBackward, selectSubwordForward, selectSyntaxLeft, selectSyntaxRight, simplifySelection, splitLine, standardKeymap, temporarilySetTabFocusMode, toggleBlockComment, toggleBlockCommentByLine, toggleComment, toggleLineComment, toggleTabFocusMode, transposeChars, undo, undoDepth, undoSelection */
10840
+ /* unused harmony exports addCursorAbove, addCursorBelow, blockComment, blockUncomment, copyLineDown, copyLineUp, cursorCharBackward, cursorCharBackwardLogical, cursorCharForward, cursorCharForwardLogical, cursorCharLeft, cursorCharRight, cursorDocEnd, cursorDocStart, cursorGroupBackward, cursorGroupForward, cursorGroupForwardWin, cursorGroupLeft, cursorGroupRight, cursorLineBoundaryBackward, cursorLineBoundaryForward, cursorLineBoundaryLeft, cursorLineBoundaryRight, cursorLineDown, cursorLineEnd, cursorLineStart, cursorLineUp, cursorMatchingBracket, cursorPageDown, cursorPageUp, cursorSubwordBackward, cursorSubwordForward, cursorSyntaxLeft, cursorSyntaxRight, deleteCharBackward, deleteCharBackwardStrict, deleteCharForward, deleteGroupBackward, deleteGroupForward, deleteGroupForwardWin, deleteLine, deleteLineBoundaryBackward, deleteLineBoundaryForward, deleteToLineEnd, deleteToLineStart, deleteTrailingWhitespace, emacsStyleKeymap, historyField, indentLess, indentMore, indentSelection, insertBlankLine, insertNewline, insertNewlineAndIndent, insertNewlineKeepIndent, insertTab, invertedEffects, isolateHistory, lineComment, lineUncomment, moveLineDown, moveLineUp, redo, redoDepth, redoSelection, selectAll, selectCharBackward, selectCharBackwardLogical, selectCharForward, selectCharForwardLogical, selectCharLeft, selectCharRight, selectDocEnd, selectDocStart, selectGroupBackward, selectGroupForward, selectGroupForwardWin, selectGroupLeft, selectGroupRight, selectLine, selectLineBoundaryBackward, selectLineBoundaryForward, selectLineBoundaryLeft, selectLineBoundaryRight, selectLineDown, selectLineEnd, selectLineStart, selectLineUp, selectMatchingBracket, selectPageDown, selectPageUp, selectParentSyntax, selectSubwordBackward, selectSubwordForward, selectSyntaxLeft, selectSyntaxRight, simplifySelection, splitLine, standardKeymap, temporarilySetTabFocusMode, toggleBlockComment, toggleBlockCommentByLine, toggleComment, toggleLineComment, toggleTabFocusMode, transposeChars, undo, undoDepth, undoSelection */
10746
10841
  /* harmony import */ var _codemirror_state__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(60);
10747
10842
  /* harmony import */ var _codemirror_view__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(730);
10748
10843
  /* harmony import */ var _codemirror_language__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(194);
@@ -11836,6 +11931,41 @@ const selectParentSyntax = ({ state, dispatch }) => {
11836
11931
  dispatch(setSel(state, selection));
11837
11932
  return true;
11838
11933
  };
11934
+ function addCursorVertically(view, forward) {
11935
+ let { state } = view, sel = state.selection, ranges = state.selection.ranges.slice();
11936
+ for (let range of state.selection.ranges) {
11937
+ let line = state.doc.lineAt(range.head);
11938
+ if (forward ? line.to < view.state.doc.length : line.from > 0)
11939
+ for (let cur = range;;) {
11940
+ let next = view.moveVertically(cur, forward);
11941
+ if (next.head < line.from || next.head > line.to) {
11942
+ if (!ranges.some(r => r.head == next.head))
11943
+ ranges.push(next);
11944
+ break;
11945
+ }
11946
+ else if (next.head == cur.head) {
11947
+ break;
11948
+ }
11949
+ else {
11950
+ cur = next;
11951
+ }
11952
+ }
11953
+ }
11954
+ if (ranges.length == sel.ranges.length)
11955
+ return false;
11956
+ view.dispatch(setSel(state, _codemirror_state__WEBPACK_IMPORTED_MODULE_0__.EditorSelection.create(ranges, ranges.length - 1)));
11957
+ return true;
11958
+ }
11959
+ /**
11960
+ Expand the selection by adding a cursor above the heads of
11961
+ currently selected ranges.
11962
+ */
11963
+ const addCursorAbove = view => addCursorVertically(view, false);
11964
+ /**
11965
+ Expand the selection by adding a cursor below the heads of
11966
+ currently selected ranges.
11967
+ */
11968
+ const addCursorBelow = view => addCursorVertically(view, true);
11839
11969
  /**
11840
11970
  Simplify the current selection. When multiple ranges are selected,
11841
11971
  reduce it to its main range. Otherwise, if the selection is
@@ -11961,6 +12091,12 @@ Delete the selection or forward until the end of the next group.
11961
12091
  */
11962
12092
  const deleteGroupForward = target => deleteByGroup(target, true);
11963
12093
  /**
12094
+ Variant of [`deleteGroupForward`](https://codemirror.net/6/docs/ref/#commands.deleteGroupForward)
12095
+ that uses the Windows convention of also deleting the whitespace
12096
+ after a word.
12097
+ */
12098
+ const deleteGroupForwardWin = view => deleteBy(view, range => view.moveByChar(range, true, start => toGroupStart(view, range.head, start)).head);
12099
+ /**
11964
12100
  Delete the selection, or, if it is a cursor selection, delete to
11965
12101
  the end of the line. If the cursor is directly at the end of the
11966
12102
  line, delete the line break after it.
@@ -12429,12 +12565,12 @@ const standardKeymap = /*@__PURE__*/[
12429
12565
  { key: "Mod-End", run: cursorDocEnd, shift: selectDocEnd },
12430
12566
  { key: "Enter", run: insertNewlineAndIndent, shift: insertNewlineAndIndent },
12431
12567
  { key: "Mod-a", run: selectAll },
12432
- { key: "Backspace", run: deleteCharBackward, shift: deleteCharBackward },
12433
- { key: "Delete", run: deleteCharForward },
12434
- { key: "Mod-Backspace", mac: "Alt-Backspace", run: deleteGroupBackward },
12435
- { key: "Mod-Delete", mac: "Alt-Delete", run: deleteGroupForward },
12436
- { mac: "Mod-Backspace", run: deleteLineBoundaryBackward },
12437
- { mac: "Mod-Delete", run: deleteLineBoundaryForward }
12568
+ { key: "Backspace", run: deleteCharBackward, shift: deleteCharBackward, preventDefault: true },
12569
+ { key: "Delete", run: deleteCharForward, preventDefault: true },
12570
+ { key: "Mod-Backspace", mac: "Alt-Backspace", run: deleteGroupBackward, preventDefault: true },
12571
+ { key: "Mod-Delete", mac: "Alt-Delete", run: deleteGroupForward, preventDefault: true },
12572
+ { mac: "Mod-Backspace", run: deleteLineBoundaryBackward, preventDefault: true },
12573
+ { mac: "Mod-Delete", run: deleteLineBoundaryForward, preventDefault: true }
12438
12574
  ].concat(/*@__PURE__*/emacsStyleKeymap.map(b => ({ mac: b.key, run: b.run, shift: b.shift })));
12439
12575
  /**
12440
12576
  The default keymap. Includes all bindings from
@@ -12446,6 +12582,8 @@ The default keymap. Includes all bindings from
12446
12582
  - Alt-ArrowDown: [`moveLineDown`](https://codemirror.net/6/docs/ref/#commands.moveLineDown)
12447
12583
  - Shift-Alt-ArrowUp: [`copyLineUp`](https://codemirror.net/6/docs/ref/#commands.copyLineUp)
12448
12584
  - Shift-Alt-ArrowDown: [`copyLineDown`](https://codemirror.net/6/docs/ref/#commands.copyLineDown)
12585
+ - Ctrl-Alt-ArrowUp (Cmd-Alt-ArrowUp on macOS): [`addCursorAbove`](https://codemirror.net/6/docs/ref/#commands.addCursorAbove).
12586
+ - Ctrl-Alt-ArrowDown (Cmd-Alt-ArrowDown on macOS): [`addCursorBelow`](https://codemirror.net/6/docs/ref/#commands.addCursorBelow).
12449
12587
  - Escape: [`simplifySelection`](https://codemirror.net/6/docs/ref/#commands.simplifySelection)
12450
12588
  - Ctrl-Enter (Cmd-Enter on macOS): [`insertBlankLine`](https://codemirror.net/6/docs/ref/#commands.insertBlankLine)
12451
12589
  - Alt-l (Ctrl-l on macOS): [`selectLine`](https://codemirror.net/6/docs/ref/#commands.selectLine)
@@ -12466,6 +12604,8 @@ const defaultKeymap = /*@__PURE__*/[
12466
12604
  { key: "Shift-Alt-ArrowUp", run: copyLineUp },
12467
12605
  { key: "Alt-ArrowDown", run: moveLineDown },
12468
12606
  { key: "Shift-Alt-ArrowDown", run: copyLineDown },
12607
+ { key: "Mod-Alt-ArrowUp", run: addCursorAbove },
12608
+ { key: "Mod-Alt-ArrowDown", run: addCursorBelow },
12469
12609
  { key: "Escape", run: simplifySelection },
12470
12610
  { key: "Mod-Enter", run: insertBlankLine },
12471
12611
  { key: "Alt-l", mac: "Ctrl-l", run: selectLine },