@uiw/react-codemirror 4.23.6 → 4.23.8
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/codemirror.js +306 -181
- package/dist/codemirror.min.js +1 -1
- package/package.json +2 -2
package/dist/codemirror.js
CHANGED
|
@@ -140,19 +140,20 @@ class SearchCursor {
|
|
|
140
140
|
let str = (0,state_.fromCodePoint)(next), start = this.bufferStart + this.bufferPos;
|
|
141
141
|
this.bufferPos += (0,state_.codePointSize)(next);
|
|
142
142
|
let norm = this.normalize(str);
|
|
143
|
-
|
|
144
|
-
let
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
if (
|
|
148
|
-
|
|
149
|
-
|
|
143
|
+
if (norm.length)
|
|
144
|
+
for (let i = 0, pos = start;; i++) {
|
|
145
|
+
let code = norm.charCodeAt(i);
|
|
146
|
+
let match = this.match(code, pos, this.bufferPos + this.bufferStart);
|
|
147
|
+
if (i == norm.length - 1) {
|
|
148
|
+
if (match) {
|
|
149
|
+
this.value = match;
|
|
150
|
+
return this;
|
|
151
|
+
}
|
|
152
|
+
break;
|
|
150
153
|
}
|
|
151
|
-
|
|
154
|
+
if (pos == start && i < str.length && str.charCodeAt(i) == code)
|
|
155
|
+
pos++;
|
|
152
156
|
}
|
|
153
|
-
if (pos == start && i < str.length && str.charCodeAt(i) == code)
|
|
154
|
-
pos++;
|
|
155
|
-
}
|
|
156
157
|
}
|
|
157
158
|
}
|
|
158
159
|
match(code, pos, end) {
|
|
@@ -709,9 +710,11 @@ class StringQuery extends QueryType {
|
|
|
709
710
|
}
|
|
710
711
|
nextMatch(state, curFrom, curTo) {
|
|
711
712
|
let cursor = stringCursor(this.spec, state, curTo, state.doc.length).nextOverlapping();
|
|
712
|
-
if (cursor.done)
|
|
713
|
-
|
|
714
|
-
|
|
713
|
+
if (cursor.done) {
|
|
714
|
+
let end = Math.min(state.doc.length, curFrom + this.spec.unquoted.length);
|
|
715
|
+
cursor = stringCursor(this.spec, state, 0, end).nextOverlapping();
|
|
716
|
+
}
|
|
717
|
+
return cursor.done || cursor.value.from == curFrom && cursor.value.to == curTo ? null : cursor.value;
|
|
715
718
|
}
|
|
716
719
|
// Searching in reverse is, rather than implementing an inverted search
|
|
717
720
|
// cursor, done by scanning chunk after chunk forward.
|
|
@@ -729,8 +732,10 @@ class StringQuery extends QueryType {
|
|
|
729
732
|
}
|
|
730
733
|
}
|
|
731
734
|
prevMatch(state, curFrom, curTo) {
|
|
732
|
-
|
|
733
|
-
|
|
735
|
+
let found = this.prevMatchInRange(state, 0, curFrom);
|
|
736
|
+
if (!found)
|
|
737
|
+
found = this.prevMatchInRange(state, Math.max(0, curTo - this.spec.unquoted.length), state.doc.length);
|
|
738
|
+
return found && (found.from != curFrom || found.to != curTo) ? found : null;
|
|
734
739
|
}
|
|
735
740
|
getReplacement(_result) { return this.spec.unquote(this.spec.replace); }
|
|
736
741
|
matchAll(state, limit) {
|
|
@@ -974,9 +979,10 @@ const replaceNext = /*@__PURE__*/searchCommand((view, { query }) => {
|
|
|
974
979
|
let { state } = view, { from, to } = state.selection.main;
|
|
975
980
|
if (state.readOnly)
|
|
976
981
|
return false;
|
|
977
|
-
let
|
|
978
|
-
if (!
|
|
982
|
+
let match = query.nextMatch(state, from, from);
|
|
983
|
+
if (!match)
|
|
979
984
|
return false;
|
|
985
|
+
let next = match;
|
|
980
986
|
let changes = [], selection, replacement;
|
|
981
987
|
let effects = [];
|
|
982
988
|
if (next.from == from && next.to == to) {
|
|
@@ -986,7 +992,7 @@ const replaceNext = /*@__PURE__*/searchCommand((view, { query }) => {
|
|
|
986
992
|
effects.push(view_.EditorView.announce.of(state.phrase("replaced match on line $", state.doc.lineAt(from).number) + "."));
|
|
987
993
|
}
|
|
988
994
|
if (next) {
|
|
989
|
-
let off = changes.length == 0 || changes[0].from >=
|
|
995
|
+
let off = changes.length == 0 || changes[0].from >= match.to ? 0 : match.to - match.from - replacement.length;
|
|
990
996
|
selection = state_.EditorSelection.single(next.from - off, next.to - off);
|
|
991
997
|
effects.push(announceMatch(view, next));
|
|
992
998
|
effects.push(state.facet(searchConfigFacet).scrollToMatch(selection.main, view));
|
|
@@ -2098,12 +2104,12 @@ class CompletionDialog {
|
|
|
2098
2104
|
return selected == this.selected || selected >= this.options.length ? this
|
|
2099
2105
|
: new CompletionDialog(this.options, makeAttrs(id, selected), this.tooltip, this.timestamp, selected, this.disabled);
|
|
2100
2106
|
}
|
|
2101
|
-
static build(active, state, id, prev, conf) {
|
|
2107
|
+
static build(active, state, id, prev, conf, didSetActive) {
|
|
2108
|
+
if (prev && !didSetActive && active.some(s => s.isPending))
|
|
2109
|
+
return prev.setDisabled();
|
|
2102
2110
|
let options = sortOptions(active, state);
|
|
2103
|
-
if (!options.length)
|
|
2104
|
-
return prev && active.some(a => a.
|
|
2105
|
-
new CompletionDialog(prev.options, prev.attrs, prev.tooltip, prev.timestamp, prev.selected, true) : null;
|
|
2106
|
-
}
|
|
2111
|
+
if (!options.length)
|
|
2112
|
+
return prev && active.some(a => a.isPending) ? prev.setDisabled() : null;
|
|
2107
2113
|
let selected = state.facet(completionConfig).selectOnOpen ? 0 : -1;
|
|
2108
2114
|
if (prev && prev.selected != selected && prev.selected != -1) {
|
|
2109
2115
|
let selectedValue = prev.options[prev.selected].completion;
|
|
@@ -2122,6 +2128,9 @@ class CompletionDialog {
|
|
|
2122
2128
|
map(changes) {
|
|
2123
2129
|
return new CompletionDialog(this.options, this.attrs, Object.assign(Object.assign({}, this.tooltip), { pos: changes.mapPos(this.tooltip.pos) }), this.timestamp, this.selected, this.disabled);
|
|
2124
2130
|
}
|
|
2131
|
+
setDisabled() {
|
|
2132
|
+
return new CompletionDialog(this.options, this.attrs, this.tooltip, this.timestamp, this.selected, true);
|
|
2133
|
+
}
|
|
2125
2134
|
}
|
|
2126
2135
|
class CompletionState {
|
|
2127
2136
|
constructor(active, id, open) {
|
|
@@ -2143,15 +2152,15 @@ class CompletionState {
|
|
|
2143
2152
|
});
|
|
2144
2153
|
if (active.length == this.active.length && active.every((a, i) => a == this.active[i]))
|
|
2145
2154
|
active = this.active;
|
|
2146
|
-
let open = this.open;
|
|
2155
|
+
let open = this.open, didSet = tr.effects.some(e => e.is(setActiveEffect));
|
|
2147
2156
|
if (open && tr.docChanged)
|
|
2148
2157
|
open = open.map(tr.changes);
|
|
2149
2158
|
if (tr.selection || active.some(a => a.hasResult() && tr.changes.touchesRange(a.from, a.to)) ||
|
|
2150
|
-
!sameResults(active, this.active))
|
|
2151
|
-
open = CompletionDialog.build(active, state, this.id, open, conf);
|
|
2152
|
-
else if (open && open.disabled && !active.some(a => a.
|
|
2159
|
+
!sameResults(active, this.active) || didSet)
|
|
2160
|
+
open = CompletionDialog.build(active, state, this.id, open, conf, didSet);
|
|
2161
|
+
else if (open && open.disabled && !active.some(a => a.isPending))
|
|
2153
2162
|
open = null;
|
|
2154
|
-
if (!open && active.every(a => a.
|
|
2163
|
+
if (!open && active.every(a => !a.isPending) && active.some(a => a.hasResult()))
|
|
2155
2164
|
active = active.map(a => a.hasResult() ? new ActiveSource(a.source, 0 /* State.Inactive */) : a);
|
|
2156
2165
|
for (let effect of tr.effects)
|
|
2157
2166
|
if (effect.is(setSelectedEffect))
|
|
@@ -2165,9 +2174,9 @@ function sameResults(a, b) {
|
|
|
2165
2174
|
if (a == b)
|
|
2166
2175
|
return true;
|
|
2167
2176
|
for (let iA = 0, iB = 0;;) {
|
|
2168
|
-
while (iA < a.length && !a[iA].hasResult)
|
|
2177
|
+
while (iA < a.length && !a[iA].hasResult())
|
|
2169
2178
|
iA++;
|
|
2170
|
-
while (iB < b.length && !b[iB].hasResult)
|
|
2179
|
+
while (iB < b.length && !b[iB].hasResult())
|
|
2171
2180
|
iB++;
|
|
2172
2181
|
let endA = iA == a.length, endB = iB == b.length;
|
|
2173
2182
|
if (endA || endB)
|
|
@@ -2205,12 +2214,13 @@ function getUpdateType(tr, conf) {
|
|
|
2205
2214
|
: tr.docChanged ? 16 /* UpdateType.ResetIfTouching */ : 0 /* UpdateType.None */;
|
|
2206
2215
|
}
|
|
2207
2216
|
class ActiveSource {
|
|
2208
|
-
constructor(source, state,
|
|
2217
|
+
constructor(source, state, explicit = false) {
|
|
2209
2218
|
this.source = source;
|
|
2210
2219
|
this.state = state;
|
|
2211
|
-
this.
|
|
2220
|
+
this.explicit = explicit;
|
|
2212
2221
|
}
|
|
2213
2222
|
hasResult() { return false; }
|
|
2223
|
+
get isPending() { return this.state == 1 /* State.Pending */; }
|
|
2214
2224
|
update(tr, conf) {
|
|
2215
2225
|
let type = getUpdateType(tr, conf), value = this;
|
|
2216
2226
|
if ((type & 8 /* UpdateType.Reset */) || (type & 16 /* UpdateType.ResetIfTouching */) && this.touches(tr))
|
|
@@ -2220,7 +2230,7 @@ class ActiveSource {
|
|
|
2220
2230
|
value = value.updateFor(tr, type);
|
|
2221
2231
|
for (let effect of tr.effects) {
|
|
2222
2232
|
if (effect.is(startCompletionEffect))
|
|
2223
|
-
value = new ActiveSource(value.source, 1 /* State.Pending */, effect.value
|
|
2233
|
+
value = new ActiveSource(value.source, 1 /* State.Pending */, effect.value);
|
|
2224
2234
|
else if (effect.is(closeCompletionEffect))
|
|
2225
2235
|
value = new ActiveSource(value.source, 0 /* State.Inactive */);
|
|
2226
2236
|
else if (effect.is(setActiveEffect))
|
|
@@ -2231,16 +2241,15 @@ class ActiveSource {
|
|
|
2231
2241
|
return value;
|
|
2232
2242
|
}
|
|
2233
2243
|
updateFor(tr, type) { return this.map(tr.changes); }
|
|
2234
|
-
map(changes) {
|
|
2235
|
-
return changes.empty || this.explicitPos < 0 ? this : new ActiveSource(this.source, this.state, changes.mapPos(this.explicitPos));
|
|
2236
|
-
}
|
|
2244
|
+
map(changes) { return this; }
|
|
2237
2245
|
touches(tr) {
|
|
2238
2246
|
return tr.changes.touchesRange(cur(tr.state));
|
|
2239
2247
|
}
|
|
2240
2248
|
}
|
|
2241
2249
|
class ActiveResult extends ActiveSource {
|
|
2242
|
-
constructor(source,
|
|
2243
|
-
super(source,
|
|
2250
|
+
constructor(source, explicit, limit, result, from, to) {
|
|
2251
|
+
super(source, 3 /* State.Result */, explicit);
|
|
2252
|
+
this.limit = limit;
|
|
2244
2253
|
this.result = result;
|
|
2245
2254
|
this.from = from;
|
|
2246
2255
|
this.to = to;
|
|
@@ -2255,17 +2264,16 @@ class ActiveResult extends ActiveSource {
|
|
|
2255
2264
|
result = result.map(result, tr.changes);
|
|
2256
2265
|
let from = tr.changes.mapPos(this.from), to = tr.changes.mapPos(this.to, 1);
|
|
2257
2266
|
let pos = cur(tr.state);
|
|
2258
|
-
if (
|
|
2259
|
-
|
|
2260
|
-
(type & 2 /* UpdateType.Backspacing */) && cur(tr.startState) == this.from)
|
|
2267
|
+
if (pos > to || !result ||
|
|
2268
|
+
(type & 2 /* UpdateType.Backspacing */) && (cur(tr.startState) == this.from || pos < this.limit))
|
|
2261
2269
|
return new ActiveSource(this.source, type & 4 /* UpdateType.Activate */ ? 1 /* State.Pending */ : 0 /* State.Inactive */);
|
|
2262
|
-
let
|
|
2270
|
+
let limit = tr.changes.mapPos(this.limit);
|
|
2263
2271
|
if (checkValid(result.validFor, tr.state, from, to))
|
|
2264
|
-
return new ActiveResult(this.source,
|
|
2272
|
+
return new ActiveResult(this.source, this.explicit, limit, result, from, to);
|
|
2265
2273
|
if (result.update &&
|
|
2266
|
-
(result = result.update(result, from, to, new CompletionContext(tr.state, pos,
|
|
2267
|
-
return new ActiveResult(this.source,
|
|
2268
|
-
return new ActiveSource(this.source, 1 /* State.Pending */,
|
|
2274
|
+
(result = result.update(result, from, to, new CompletionContext(tr.state, pos, false))))
|
|
2275
|
+
return new ActiveResult(this.source, this.explicit, limit, result, result.from, (_a = result.to) !== null && _a !== void 0 ? _a : cur(tr.state));
|
|
2276
|
+
return new ActiveSource(this.source, 1 /* State.Pending */, this.explicit);
|
|
2269
2277
|
}
|
|
2270
2278
|
map(mapping) {
|
|
2271
2279
|
if (mapping.empty)
|
|
@@ -2273,7 +2281,7 @@ class ActiveResult extends ActiveSource {
|
|
|
2273
2281
|
let result = this.result.map ? this.result.map(this.result, mapping) : this.result;
|
|
2274
2282
|
if (!result)
|
|
2275
2283
|
return new ActiveSource(this.source, 0 /* State.Inactive */);
|
|
2276
|
-
return new ActiveResult(this.source, this.
|
|
2284
|
+
return new ActiveResult(this.source, this.explicit, mapping.mapPos(this.limit), this.result, mapping.mapPos(this.from), mapping.mapPos(this.to, 1));
|
|
2277
2285
|
}
|
|
2278
2286
|
touches(tr) {
|
|
2279
2287
|
return tr.changes.touchesRange(this.from, this.to);
|
|
@@ -2385,7 +2393,7 @@ const completionPlugin = /*@__PURE__*/view_.ViewPlugin.fromClass(class {
|
|
|
2385
2393
|
this.pendingStart = false;
|
|
2386
2394
|
this.composing = 0 /* CompositionState.None */;
|
|
2387
2395
|
for (let active of view.state.field(completionState).active)
|
|
2388
|
-
if (active.
|
|
2396
|
+
if (active.isPending)
|
|
2389
2397
|
this.startQuery(active);
|
|
2390
2398
|
}
|
|
2391
2399
|
update(update) {
|
|
@@ -2422,7 +2430,7 @@ const completionPlugin = /*@__PURE__*/view_.ViewPlugin.fromClass(class {
|
|
|
2422
2430
|
if (update.transactions.some(tr => tr.effects.some(e => e.is(startCompletionEffect))))
|
|
2423
2431
|
this.pendingStart = true;
|
|
2424
2432
|
let delay = this.pendingStart ? 50 : conf.activateOnTypingDelay;
|
|
2425
|
-
this.debounceUpdate = cState.active.some(a => a.
|
|
2433
|
+
this.debounceUpdate = cState.active.some(a => a.isPending && !this.running.some(q => q.active.source == a.source))
|
|
2426
2434
|
? setTimeout(() => this.startUpdate(), delay) : -1;
|
|
2427
2435
|
if (this.composing != 0 /* CompositionState.None */)
|
|
2428
2436
|
for (let tr of update.transactions) {
|
|
@@ -2437,13 +2445,15 @@ const completionPlugin = /*@__PURE__*/view_.ViewPlugin.fromClass(class {
|
|
|
2437
2445
|
this.pendingStart = false;
|
|
2438
2446
|
let { state } = this.view, cState = state.field(completionState);
|
|
2439
2447
|
for (let active of cState.active) {
|
|
2440
|
-
if (active.
|
|
2448
|
+
if (active.isPending && !this.running.some(r => r.active.source == active.source))
|
|
2441
2449
|
this.startQuery(active);
|
|
2442
2450
|
}
|
|
2451
|
+
if (this.running.length && cState.open && cState.open.disabled)
|
|
2452
|
+
this.debounceAccept = setTimeout(() => this.accept(), this.view.state.facet(completionConfig).updateSyncTime);
|
|
2443
2453
|
}
|
|
2444
2454
|
startQuery(active) {
|
|
2445
2455
|
let { state } = this.view, pos = cur(state);
|
|
2446
|
-
let context = new CompletionContext(state, pos, active.
|
|
2456
|
+
let context = new CompletionContext(state, pos, active.explicit, this.view);
|
|
2447
2457
|
let pending = new RunningQuery(active, context);
|
|
2448
2458
|
this.running.push(pending);
|
|
2449
2459
|
Promise.resolve(active.source(context)).then(result => {
|
|
@@ -2470,14 +2480,16 @@ const completionPlugin = /*@__PURE__*/view_.ViewPlugin.fromClass(class {
|
|
|
2470
2480
|
clearTimeout(this.debounceAccept);
|
|
2471
2481
|
this.debounceAccept = -1;
|
|
2472
2482
|
let updated = [];
|
|
2473
|
-
let conf = this.view.state.facet(completionConfig);
|
|
2483
|
+
let conf = this.view.state.facet(completionConfig), cState = this.view.state.field(completionState);
|
|
2474
2484
|
for (let i = 0; i < this.running.length; i++) {
|
|
2475
2485
|
let query = this.running[i];
|
|
2476
2486
|
if (query.done === undefined)
|
|
2477
2487
|
continue;
|
|
2478
2488
|
this.running.splice(i--, 1);
|
|
2479
2489
|
if (query.done) {
|
|
2480
|
-
let
|
|
2490
|
+
let pos = cur(query.updates.length ? query.updates[0].startState : this.view.state);
|
|
2491
|
+
let limit = Math.min(pos, query.done.from + (query.active.explicit ? 0 : 1));
|
|
2492
|
+
let active = new ActiveResult(query.active.source, query.active.explicit, limit, query.done, query.done.from, (_a = query.done.to) !== null && _a !== void 0 ? _a : pos);
|
|
2481
2493
|
// Replay the transactions that happened since the start of
|
|
2482
2494
|
// the request and see if that preserves the result
|
|
2483
2495
|
for (let tr of query.updates)
|
|
@@ -2487,15 +2499,15 @@ const completionPlugin = /*@__PURE__*/view_.ViewPlugin.fromClass(class {
|
|
|
2487
2499
|
continue;
|
|
2488
2500
|
}
|
|
2489
2501
|
}
|
|
2490
|
-
let current =
|
|
2491
|
-
if (current && current.
|
|
2502
|
+
let current = cState.active.find(a => a.source == query.active.source);
|
|
2503
|
+
if (current && current.isPending) {
|
|
2492
2504
|
if (query.done == null) {
|
|
2493
2505
|
// Explicitly failed. Should clear the pending status if it
|
|
2494
2506
|
// hasn't been re-set in the meantime.
|
|
2495
2507
|
let active = new ActiveSource(query.active.source, 0 /* State.Inactive */);
|
|
2496
2508
|
for (let tr of query.updates)
|
|
2497
2509
|
active = active.update(tr, conf);
|
|
2498
|
-
if (active.
|
|
2510
|
+
if (!active.isPending)
|
|
2499
2511
|
updated.push(active);
|
|
2500
2512
|
}
|
|
2501
2513
|
else {
|
|
@@ -2504,7 +2516,7 @@ const completionPlugin = /*@__PURE__*/view_.ViewPlugin.fromClass(class {
|
|
|
2504
2516
|
}
|
|
2505
2517
|
}
|
|
2506
2518
|
}
|
|
2507
|
-
if (updated.length)
|
|
2519
|
+
if (updated.length || cState.open && cState.open.disabled)
|
|
2508
2520
|
this.view.dispatch({ effects: setActiveEffect.of(updated) });
|
|
2509
2521
|
}
|
|
2510
2522
|
}, {
|
|
@@ -2836,8 +2848,9 @@ function snippet(template) {
|
|
|
2836
2848
|
let snippet = Snippet.parse(template);
|
|
2837
2849
|
return (editor, completion, from, to) => {
|
|
2838
2850
|
let { text, ranges } = snippet.instantiate(editor.state, from);
|
|
2851
|
+
let { main } = editor.state.selection;
|
|
2839
2852
|
let spec = {
|
|
2840
|
-
changes: { from, to, insert: Text.of(text) },
|
|
2853
|
+
changes: { from, to: to == main.from ? main.to : to, insert: Text.of(text) },
|
|
2841
2854
|
scrollIntoView: true,
|
|
2842
2855
|
annotations: completion ? [pickedCompletion.of(completion), Transaction.userEvent.of("input.complete")] : undefined
|
|
2843
2856
|
};
|
|
@@ -3306,7 +3319,7 @@ returns `null`.
|
|
|
3306
3319
|
*/
|
|
3307
3320
|
function completionStatus(state) {
|
|
3308
3321
|
let cState = state.field(completionState, false);
|
|
3309
|
-
return cState && cState.active.some(a => a.
|
|
3322
|
+
return cState && cState.active.some(a => a.isPending) ? "pending"
|
|
3310
3323
|
: cState && cState.active.some(a => a.state != 0 /* State.Inactive */) ? "active" : null;
|
|
3311
3324
|
}
|
|
3312
3325
|
const completionArrayCache = /*@__PURE__*/new WeakMap;
|
|
@@ -3374,28 +3387,70 @@ class LintState {
|
|
|
3374
3387
|
let diagnosticFilter = state.facet(lintConfig).markerFilter;
|
|
3375
3388
|
if (diagnosticFilter)
|
|
3376
3389
|
markedDiagnostics = diagnosticFilter(markedDiagnostics, state);
|
|
3377
|
-
let
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
+
let sorted = diagnostics.slice().sort((a, b) => a.from - b.from || a.to - b.to);
|
|
3391
|
+
let deco = new state_.RangeSetBuilder(), active = [], pos = 0;
|
|
3392
|
+
for (let i = 0;;) {
|
|
3393
|
+
let next = i == sorted.length ? null : sorted[i];
|
|
3394
|
+
if (!next && !active.length)
|
|
3395
|
+
break;
|
|
3396
|
+
let from, to;
|
|
3397
|
+
if (active.length) {
|
|
3398
|
+
from = pos;
|
|
3399
|
+
to = active.reduce((p, d) => Math.min(p, d.to), next && next.from > from ? next.from : 1e8);
|
|
3400
|
+
}
|
|
3401
|
+
else {
|
|
3402
|
+
from = next.from;
|
|
3403
|
+
to = next.to;
|
|
3404
|
+
active.push(next);
|
|
3405
|
+
i++;
|
|
3406
|
+
}
|
|
3407
|
+
while (i < sorted.length) {
|
|
3408
|
+
let next = sorted[i];
|
|
3409
|
+
if (next.from == from && (next.to > next.from || next.to == from)) {
|
|
3410
|
+
active.push(next);
|
|
3411
|
+
i++;
|
|
3412
|
+
to = Math.min(next.to, to);
|
|
3413
|
+
}
|
|
3414
|
+
else {
|
|
3415
|
+
to = Math.min(next.from, to);
|
|
3416
|
+
break;
|
|
3417
|
+
}
|
|
3418
|
+
}
|
|
3419
|
+
let sev = maxSeverity(active);
|
|
3420
|
+
if (active.some(d => d.from == d.to || (d.from == d.to - 1 && state.doc.lineAt(d.from).to == d.from))) {
|
|
3421
|
+
deco.add(from, from, view_.Decoration.widget({
|
|
3422
|
+
widget: new DiagnosticWidget(sev),
|
|
3423
|
+
diagnostics: active.slice()
|
|
3424
|
+
}));
|
|
3425
|
+
}
|
|
3426
|
+
else {
|
|
3427
|
+
let markClass = active.reduce((c, d) => d.markClass ? c + " " + d.markClass : c, "");
|
|
3428
|
+
deco.add(from, to, view_.Decoration.mark({
|
|
3429
|
+
class: "cm-lintRange cm-lintRange-" + sev + markClass,
|
|
3430
|
+
diagnostics: active.slice(),
|
|
3431
|
+
inclusiveEnd: active.some(a => a.to > to)
|
|
3432
|
+
}));
|
|
3433
|
+
}
|
|
3434
|
+
pos = to;
|
|
3435
|
+
for (let i = 0; i < active.length; i++)
|
|
3436
|
+
if (active[i].to <= pos)
|
|
3437
|
+
active.splice(i--, 1);
|
|
3438
|
+
}
|
|
3439
|
+
let set = deco.finish();
|
|
3440
|
+
return new LintState(set, panel, findDiagnostic(set));
|
|
3390
3441
|
}
|
|
3391
3442
|
}
|
|
3392
3443
|
function findDiagnostic(diagnostics, diagnostic = null, after = 0) {
|
|
3393
3444
|
let found = null;
|
|
3394
3445
|
diagnostics.between(after, 1e9, (from, to, { spec }) => {
|
|
3395
|
-
if (diagnostic && spec.diagnostic
|
|
3446
|
+
if (diagnostic && spec.diagnostics.indexOf(diagnostic) < 0)
|
|
3396
3447
|
return;
|
|
3397
|
-
|
|
3398
|
-
|
|
3448
|
+
if (!found)
|
|
3449
|
+
found = new SelectedDiagnostic(from, to, diagnostic || spec.diagnostics[0]);
|
|
3450
|
+
else if (spec.diagnostics.indexOf(found.diagnostic) < 0)
|
|
3451
|
+
return false;
|
|
3452
|
+
else
|
|
3453
|
+
found = new SelectedDiagnostic(found.from, to, found.diagnostic);
|
|
3399
3454
|
});
|
|
3400
3455
|
return found;
|
|
3401
3456
|
}
|
|
@@ -3469,24 +3524,25 @@ function diagnosticCount(state) {
|
|
|
3469
3524
|
const activeMark = /*@__PURE__*/view_.Decoration.mark({ class: "cm-lintRange cm-lintRange-active" });
|
|
3470
3525
|
function lintTooltip(view, pos, side) {
|
|
3471
3526
|
let { diagnostics } = view.state.field(lintState);
|
|
3472
|
-
let found
|
|
3527
|
+
let found, start = -1, end = -1;
|
|
3473
3528
|
diagnostics.between(pos - (side < 0 ? 1 : 0), pos + (side > 0 ? 1 : 0), (from, to, { spec }) => {
|
|
3474
3529
|
if (pos >= from && pos <= to &&
|
|
3475
3530
|
(from == to || ((pos > from || side > 0) && (pos < to || side < 0)))) {
|
|
3476
|
-
found
|
|
3477
|
-
|
|
3478
|
-
|
|
3531
|
+
found = spec.diagnostics;
|
|
3532
|
+
start = from;
|
|
3533
|
+
end = to;
|
|
3534
|
+
return false;
|
|
3479
3535
|
}
|
|
3480
3536
|
});
|
|
3481
3537
|
let diagnosticFilter = view.state.facet(lintConfig).tooltipFilter;
|
|
3482
|
-
if (diagnosticFilter)
|
|
3538
|
+
if (found && diagnosticFilter)
|
|
3483
3539
|
found = diagnosticFilter(found, view.state);
|
|
3484
|
-
if (!found
|
|
3540
|
+
if (!found)
|
|
3485
3541
|
return null;
|
|
3486
3542
|
return {
|
|
3487
|
-
pos:
|
|
3488
|
-
end:
|
|
3489
|
-
above: view.state.doc.lineAt(
|
|
3543
|
+
pos: start,
|
|
3544
|
+
end: end,
|
|
3545
|
+
above: view.state.doc.lineAt(start).to < end,
|
|
3490
3546
|
create() {
|
|
3491
3547
|
return { dom: diagnosticsTooltip(view, found) };
|
|
3492
3548
|
}
|
|
@@ -3623,7 +3679,7 @@ function batchResults(promises, sink, error) {
|
|
|
3623
3679
|
if (collected.length == promises.length)
|
|
3624
3680
|
sink(collected);
|
|
3625
3681
|
else
|
|
3626
|
-
setTimeout(() => sink(collected), 200);
|
|
3682
|
+
timeout = setTimeout(() => sink(collected), 200);
|
|
3627
3683
|
}, error);
|
|
3628
3684
|
}
|
|
3629
3685
|
const lintConfig = /*@__PURE__*/state_.Facet.define({
|
|
@@ -3703,13 +3759,13 @@ function renderDiagnostic(view, diagnostic, inPanel) {
|
|
|
3703
3759
|
}), diagnostic.source && crelt("div", { class: "cm-diagnosticSource" }, diagnostic.source));
|
|
3704
3760
|
}
|
|
3705
3761
|
class DiagnosticWidget extends view_.WidgetType {
|
|
3706
|
-
constructor(
|
|
3762
|
+
constructor(sev) {
|
|
3707
3763
|
super();
|
|
3708
|
-
this.
|
|
3764
|
+
this.sev = sev;
|
|
3709
3765
|
}
|
|
3710
|
-
eq(other) { return other.
|
|
3766
|
+
eq(other) { return other.sev == this.sev; }
|
|
3711
3767
|
toDOM() {
|
|
3712
|
-
return crelt("span", { class: "cm-lintPoint cm-lintPoint-" + this.
|
|
3768
|
+
return crelt("span", { class: "cm-lintPoint cm-lintPoint-" + this.sev });
|
|
3713
3769
|
}
|
|
3714
3770
|
}
|
|
3715
3771
|
class PanelItem {
|
|
@@ -3792,35 +3848,41 @@ class LintPanel {
|
|
|
3792
3848
|
update() {
|
|
3793
3849
|
let { diagnostics, selected } = this.view.state.field(lintState);
|
|
3794
3850
|
let i = 0, needsSync = false, newSelectedItem = null;
|
|
3851
|
+
let seen = new Set();
|
|
3795
3852
|
diagnostics.between(0, this.view.state.doc.length, (_start, _end, { spec }) => {
|
|
3796
|
-
let
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
if (found > i) {
|
|
3810
|
-
this.items.splice(i, found - i);
|
|
3853
|
+
for (let diagnostic of spec.diagnostics) {
|
|
3854
|
+
if (seen.has(diagnostic))
|
|
3855
|
+
continue;
|
|
3856
|
+
seen.add(diagnostic);
|
|
3857
|
+
let found = -1, item;
|
|
3858
|
+
for (let j = i; j < this.items.length; j++)
|
|
3859
|
+
if (this.items[j].diagnostic == diagnostic) {
|
|
3860
|
+
found = j;
|
|
3861
|
+
break;
|
|
3862
|
+
}
|
|
3863
|
+
if (found < 0) {
|
|
3864
|
+
item = new PanelItem(this.view, diagnostic);
|
|
3865
|
+
this.items.splice(i, 0, item);
|
|
3811
3866
|
needsSync = true;
|
|
3812
3867
|
}
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
|
|
3868
|
+
else {
|
|
3869
|
+
item = this.items[found];
|
|
3870
|
+
if (found > i) {
|
|
3871
|
+
this.items.splice(i, found - i);
|
|
3872
|
+
needsSync = true;
|
|
3873
|
+
}
|
|
3818
3874
|
}
|
|
3875
|
+
if (selected && item.diagnostic == selected.diagnostic) {
|
|
3876
|
+
if (!item.dom.hasAttribute("aria-selected")) {
|
|
3877
|
+
item.dom.setAttribute("aria-selected", "true");
|
|
3878
|
+
newSelectedItem = item;
|
|
3879
|
+
}
|
|
3880
|
+
}
|
|
3881
|
+
else if (item.dom.hasAttribute("aria-selected")) {
|
|
3882
|
+
item.dom.removeAttribute("aria-selected");
|
|
3883
|
+
}
|
|
3884
|
+
i++;
|
|
3819
3885
|
}
|
|
3820
|
-
else if (item.dom.hasAttribute("aria-selected")) {
|
|
3821
|
-
item.dom.removeAttribute("aria-selected");
|
|
3822
|
-
}
|
|
3823
|
-
i++;
|
|
3824
3886
|
});
|
|
3825
3887
|
while (i < this.items.length && !(this.items.length == 1 && this.items[0].diagnostic.from < 0)) {
|
|
3826
3888
|
needsSync = true;
|
|
@@ -3989,11 +4051,22 @@ const lint_dist_baseTheme = /*@__PURE__*/view_.EditorView.baseTheme({
|
|
|
3989
4051
|
function severityWeight(sev) {
|
|
3990
4052
|
return sev == "error" ? 4 : sev == "warning" ? 3 : sev == "info" ? 2 : 1;
|
|
3991
4053
|
}
|
|
4054
|
+
function maxSeverity(diagnostics) {
|
|
4055
|
+
let sev = "hint", weight = 1;
|
|
4056
|
+
for (let d of diagnostics) {
|
|
4057
|
+
let w = severityWeight(d.severity);
|
|
4058
|
+
if (w > weight) {
|
|
4059
|
+
weight = w;
|
|
4060
|
+
sev = d.severity;
|
|
4061
|
+
}
|
|
4062
|
+
}
|
|
4063
|
+
return sev;
|
|
4064
|
+
}
|
|
3992
4065
|
class LintGutterMarker extends view_.GutterMarker {
|
|
3993
4066
|
constructor(diagnostics) {
|
|
3994
4067
|
super();
|
|
3995
4068
|
this.diagnostics = diagnostics;
|
|
3996
|
-
this.severity = diagnostics
|
|
4069
|
+
this.severity = maxSeverity(diagnostics);
|
|
3997
4070
|
}
|
|
3998
4071
|
toDOM(view) {
|
|
3999
4072
|
let elt = document.createElement("div");
|
|
@@ -4031,6 +4104,7 @@ function gutterMarkerMouseOver(view, marker, diagnostics) {
|
|
|
4031
4104
|
view.dispatch({ effects: setLintGutterTooltip.of({
|
|
4032
4105
|
pos: line.from,
|
|
4033
4106
|
above: false,
|
|
4107
|
+
clip: false,
|
|
4034
4108
|
create() {
|
|
4035
4109
|
return {
|
|
4036
4110
|
dom: diagnosticsTooltip(view, diagnostics),
|
|
@@ -4071,7 +4145,8 @@ const lintGutterExtension = /*@__PURE__*/(0,view_.gutter)({
|
|
|
4071
4145
|
widgetMarker: (view, widget, block) => {
|
|
4072
4146
|
let diagnostics = [];
|
|
4073
4147
|
view.state.field(lintGutterMarkers).between(block.from, block.to, (from, to, value) => {
|
|
4074
|
-
|
|
4148
|
+
if (from > block.from && from < block.to)
|
|
4149
|
+
diagnostics.push(...value.diagnostics);
|
|
4075
4150
|
});
|
|
4076
4151
|
return diagnostics.length ? new LintGutterMarker(diagnostics) : null;
|
|
4077
4152
|
}
|
|
@@ -4162,9 +4237,25 @@ arguments hold the diagnostic's current position.
|
|
|
4162
4237
|
*/
|
|
4163
4238
|
function forEachDiagnostic(state, f) {
|
|
4164
4239
|
let lState = state.field(lintState, false);
|
|
4165
|
-
if (lState && lState.diagnostics.size)
|
|
4166
|
-
|
|
4167
|
-
|
|
4240
|
+
if (lState && lState.diagnostics.size) {
|
|
4241
|
+
let pending = [], pendingStart = [], lastEnd = -1;
|
|
4242
|
+
for (let iter = RangeSet.iter([lState.diagnostics]);; iter.next()) {
|
|
4243
|
+
for (let i = 0; i < pending.length; i++)
|
|
4244
|
+
if (!iter.value || iter.value.spec.diagnostics.indexOf(pending[i]) < 0) {
|
|
4245
|
+
f(pending[i], pendingStart[i], lastEnd);
|
|
4246
|
+
pending.splice(i, 1);
|
|
4247
|
+
pendingStart.splice(i--, 1);
|
|
4248
|
+
}
|
|
4249
|
+
if (!iter.value)
|
|
4250
|
+
break;
|
|
4251
|
+
for (let d of iter.value.spec.diagnostics)
|
|
4252
|
+
if (pending.indexOf(d) < 0) {
|
|
4253
|
+
pending.push(d);
|
|
4254
|
+
pendingStart.push(iter.from);
|
|
4255
|
+
}
|
|
4256
|
+
lastEnd = iter.to;
|
|
4257
|
+
}
|
|
4258
|
+
}
|
|
4168
4259
|
}
|
|
4169
4260
|
|
|
4170
4261
|
|
|
@@ -4588,7 +4679,7 @@ function _objectWithoutPropertiesLoose(r, e) {
|
|
|
4588
4679
|
if (null == r) return {};
|
|
4589
4680
|
var t = {};
|
|
4590
4681
|
for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
|
|
4591
|
-
if (e.
|
|
4682
|
+
if (-1 !== e.indexOf(n)) continue;
|
|
4592
4683
|
t[n] = r[n];
|
|
4593
4684
|
}
|
|
4594
4685
|
return t;
|
|
@@ -4602,8 +4693,8 @@ function _objectWithoutProperties(e, t) {
|
|
|
4602
4693
|
r,
|
|
4603
4694
|
i = _objectWithoutPropertiesLoose(e, t);
|
|
4604
4695
|
if (Object.getOwnPropertySymbols) {
|
|
4605
|
-
var
|
|
4606
|
-
for (r = 0; r <
|
|
4696
|
+
var n = Object.getOwnPropertySymbols(e);
|
|
4697
|
+
for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
|
|
4607
4698
|
}
|
|
4608
4699
|
return i;
|
|
4609
4700
|
}
|
|
@@ -4620,7 +4711,7 @@ function _objectWithoutProperties(e, t) {
|
|
|
4620
4711
|
/* harmony export */ cL: () => (/* binding */ historyKeymap),
|
|
4621
4712
|
/* harmony export */ pw: () => (/* binding */ defaultKeymap)
|
|
4622
4713
|
/* harmony export */ });
|
|
4623
|
-
/* unused harmony exports blockComment, blockUncomment, copyLineDown, copyLineUp, cursorCharBackward, cursorCharBackwardLogical, cursorCharForward, cursorCharForwardLogical, cursorCharLeft, cursorCharRight, cursorDocEnd, cursorDocStart, cursorGroupBackward, cursorGroupForward, 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, 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 */
|
|
4714
|
+
/* 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 */
|
|
4624
4715
|
/* harmony import */ var _codemirror_state__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(60);
|
|
4625
4716
|
/* harmony import */ var _codemirror_view__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(730);
|
|
4626
4717
|
/* harmony import */ var _codemirror_language__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(194);
|
|
@@ -5261,6 +5352,26 @@ const cursorGroupForward = view => cursorByGroup(view, true);
|
|
|
5261
5352
|
Move the selection one group backward.
|
|
5262
5353
|
*/
|
|
5263
5354
|
const cursorGroupBackward = view => cursorByGroup(view, false);
|
|
5355
|
+
function toGroupStart(view, pos, start) {
|
|
5356
|
+
let categorize = view.state.charCategorizer(pos);
|
|
5357
|
+
let cat = categorize(start), initial = cat != CharCategory.Space;
|
|
5358
|
+
return (next) => {
|
|
5359
|
+
let nextCat = categorize(next);
|
|
5360
|
+
if (nextCat != CharCategory.Space)
|
|
5361
|
+
return initial && nextCat == cat;
|
|
5362
|
+
initial = false;
|
|
5363
|
+
return true;
|
|
5364
|
+
};
|
|
5365
|
+
}
|
|
5366
|
+
/**
|
|
5367
|
+
Move the cursor one group forward in the default Windows style,
|
|
5368
|
+
where it moves to the start of the next group.
|
|
5369
|
+
*/
|
|
5370
|
+
const cursorGroupForwardWin = view => {
|
|
5371
|
+
return moveSel(view, range => range.empty
|
|
5372
|
+
? view.moveByChar(range, true, start => toGroupStart(view, range.head, start))
|
|
5373
|
+
: rangeEnd(range, true));
|
|
5374
|
+
};
|
|
5264
5375
|
const segmenter = typeof Intl != "undefined" && Intl.Segmenter ?
|
|
5265
5376
|
/*@__PURE__*/new (Intl.Segmenter)(undefined, { granularity: "word" }) : null;
|
|
5266
5377
|
function moveBySubword(view, range, forward) {
|
|
@@ -5551,6 +5662,13 @@ const selectGroupForward = view => selectByGroup(view, true);
|
|
|
5551
5662
|
Move the selection head one group backward.
|
|
5552
5663
|
*/
|
|
5553
5664
|
const selectGroupBackward = view => selectByGroup(view, false);
|
|
5665
|
+
/**
|
|
5666
|
+
Move the selection head one group forward in the default Windows
|
|
5667
|
+
style, skipping to the start of the next group.
|
|
5668
|
+
*/
|
|
5669
|
+
const selectGroupForwardWin = view => {
|
|
5670
|
+
return extendSel(view, range => view.moveByChar(range, true, start => toGroupStart(view, range.head, start)));
|
|
5671
|
+
};
|
|
5554
5672
|
function selectBySubword(view, forward) {
|
|
5555
5673
|
return extendSel(view, range => moveBySubword(view, range, forward));
|
|
5556
5674
|
}
|
|
@@ -8448,10 +8566,10 @@ const indentNodeProp = /*@__PURE__*/new dist/* NodeProp */.uY();
|
|
|
8448
8566
|
// Compute the indentation for a given position from the syntax tree.
|
|
8449
8567
|
function syntaxIndentation(cx, ast, pos) {
|
|
8450
8568
|
let stack = ast.resolveStack(pos);
|
|
8451
|
-
let inner =
|
|
8569
|
+
let inner = ast.resolveInner(pos, -1).resolve(pos, 0).enterUnfinishedNodesBefore(pos);
|
|
8452
8570
|
if (inner != stack.node) {
|
|
8453
8571
|
let add = [];
|
|
8454
|
-
for (let cur = inner; cur
|
|
8572
|
+
for (let cur = inner; cur && !(cur.from == stack.node.from && cur.type == stack.node.type); cur = cur.parent)
|
|
8455
8573
|
add.push(cur);
|
|
8456
8574
|
for (let i = add.length - 1; i >= 0; i--)
|
|
8457
8575
|
stack = { node: add[i], next: stack };
|
|
@@ -9661,8 +9779,8 @@ class StreamLanguage extends Language {
|
|
|
9661
9779
|
return new Parse(self, input, fragments, ranges);
|
|
9662
9780
|
}
|
|
9663
9781
|
};
|
|
9664
|
-
super(data, impl, [
|
|
9665
|
-
this.topNode = docID(data);
|
|
9782
|
+
super(data, impl, [], parser.name);
|
|
9783
|
+
this.topNode = docID(data, this);
|
|
9666
9784
|
self = this;
|
|
9667
9785
|
this.streamParser = p;
|
|
9668
9786
|
this.stateAfter = new dist/* NodeProp */.uY({ perNode: true });
|
|
@@ -9672,32 +9790,30 @@ class StreamLanguage extends Language {
|
|
|
9672
9790
|
Define a stream language.
|
|
9673
9791
|
*/
|
|
9674
9792
|
static define(spec) { return new StreamLanguage(spec); }
|
|
9675
|
-
|
|
9676
|
-
|
|
9677
|
-
|
|
9678
|
-
|
|
9679
|
-
if (!at)
|
|
9680
|
-
return null;
|
|
9793
|
+
/**
|
|
9794
|
+
@internal
|
|
9795
|
+
*/
|
|
9796
|
+
getIndent(cx) {
|
|
9681
9797
|
let from = undefined;
|
|
9682
9798
|
let { overrideIndentation } = cx.options;
|
|
9683
9799
|
if (overrideIndentation) {
|
|
9684
9800
|
from = IndentedFrom.get(cx.state);
|
|
9685
|
-
if (from != null && from < pos - 1e4)
|
|
9801
|
+
if (from != null && from < cx.pos - 1e4)
|
|
9686
9802
|
from = undefined;
|
|
9687
9803
|
}
|
|
9688
|
-
let start = findState(this, tree,
|
|
9804
|
+
let start = findState(this, cx.node.tree, cx.node.from, cx.node.from, from !== null && from !== void 0 ? from : cx.pos), statePos, state;
|
|
9689
9805
|
if (start) {
|
|
9690
9806
|
state = start.state;
|
|
9691
9807
|
statePos = start.pos + 1;
|
|
9692
9808
|
}
|
|
9693
9809
|
else {
|
|
9694
9810
|
state = this.streamParser.startState(cx.unit);
|
|
9695
|
-
statePos =
|
|
9811
|
+
statePos = cx.node.from;
|
|
9696
9812
|
}
|
|
9697
|
-
if (pos - statePos > 10000 /* C.MaxIndentScanDist */)
|
|
9813
|
+
if (cx.pos - statePos > 10000 /* C.MaxIndentScanDist */)
|
|
9698
9814
|
return null;
|
|
9699
|
-
while (statePos < pos) {
|
|
9700
|
-
let line = cx.state.doc.lineAt(statePos), end = Math.min(pos, line.to);
|
|
9815
|
+
while (statePos < cx.pos) {
|
|
9816
|
+
let line = cx.state.doc.lineAt(statePos), end = Math.min(cx.pos, line.to);
|
|
9701
9817
|
if (line.length) {
|
|
9702
9818
|
let indentation = overrideIndentation ? overrideIndentation(line.from) : -1;
|
|
9703
9819
|
let stream = new StringStream(line.text, cx.state.tabSize, cx.unit, indentation < 0 ? undefined : indentation);
|
|
@@ -9707,11 +9823,11 @@ class StreamLanguage extends Language {
|
|
|
9707
9823
|
else {
|
|
9708
9824
|
this.streamParser.blankLine(state, cx.unit);
|
|
9709
9825
|
}
|
|
9710
|
-
if (end == pos)
|
|
9826
|
+
if (end == cx.pos)
|
|
9711
9827
|
break;
|
|
9712
9828
|
statePos = line.to + 1;
|
|
9713
9829
|
}
|
|
9714
|
-
let line = cx.lineAt(pos);
|
|
9830
|
+
let line = cx.lineAt(cx.pos);
|
|
9715
9831
|
if (overrideIndentation && from == null)
|
|
9716
9832
|
IndentedFrom.set(cx.state, line.from);
|
|
9717
9833
|
return this.streamParser.indent(state, /^\s*(.*)/.exec(line.text)[1], cx);
|
|
@@ -9733,7 +9849,7 @@ function findState(lang, tree, off, startPos, before) {
|
|
|
9733
9849
|
function cutTree(lang, tree, from, to, inside) {
|
|
9734
9850
|
if (inside && from <= 0 && to >= tree.length)
|
|
9735
9851
|
return tree;
|
|
9736
|
-
if (!inside && tree.type == lang.topNode)
|
|
9852
|
+
if (!inside && from == 0 && tree.type == lang.topNode)
|
|
9737
9853
|
inside = true;
|
|
9738
9854
|
for (let i = tree.children.length - 1; i >= 0; i--) {
|
|
9739
9855
|
let pos = tree.positions[i], child = tree.children[i], inner;
|
|
@@ -9746,11 +9862,11 @@ function cutTree(lang, tree, from, to, inside) {
|
|
|
9746
9862
|
}
|
|
9747
9863
|
return null;
|
|
9748
9864
|
}
|
|
9749
|
-
function findStartInFragments(lang, fragments, startPos, editorState) {
|
|
9865
|
+
function findStartInFragments(lang, fragments, startPos, endPos, editorState) {
|
|
9750
9866
|
for (let f of fragments) {
|
|
9751
9867
|
let from = f.from + (f.openStart ? 25 : 0), to = f.to - (f.openEnd ? 25 : 0);
|
|
9752
9868
|
let found = from <= startPos && to > startPos && findState(lang, f.tree, 0 - f.offset, startPos, to), tree;
|
|
9753
|
-
if (found && (tree = cutTree(lang, f.tree, startPos + f.offset, found.pos + f.offset, false)))
|
|
9869
|
+
if (found && found.pos <= endPos && (tree = cutTree(lang, f.tree, startPos + f.offset, found.pos + f.offset, false)))
|
|
9754
9870
|
return { state: found.state, tree };
|
|
9755
9871
|
}
|
|
9756
9872
|
return { state: lang.streamParser.startState(editorState ? getIndentUnit(editorState) : 4), tree: dist/* Tree */.PH.empty };
|
|
@@ -9769,14 +9885,15 @@ class Parse {
|
|
|
9769
9885
|
this.rangeIndex = 0;
|
|
9770
9886
|
this.to = ranges[ranges.length - 1].to;
|
|
9771
9887
|
let context = ParseContext.get(), from = ranges[0].from;
|
|
9772
|
-
let { state, tree } = findStartInFragments(lang, fragments, from, context === null || context === void 0 ? void 0 : context.state);
|
|
9888
|
+
let { state, tree } = findStartInFragments(lang, fragments, from, this.to, context === null || context === void 0 ? void 0 : context.state);
|
|
9773
9889
|
this.state = state;
|
|
9774
9890
|
this.parsedPos = this.chunkStart = from + tree.length;
|
|
9775
9891
|
for (let i = 0; i < tree.children.length; i++) {
|
|
9776
9892
|
this.chunks.push(tree.children[i]);
|
|
9777
9893
|
this.chunkPos.push(tree.positions[i]);
|
|
9778
9894
|
}
|
|
9779
|
-
if (context && this.parsedPos < context.viewport.from - 100000 /* C.MaxDistanceBeforeViewport */
|
|
9895
|
+
if (context && this.parsedPos < context.viewport.from - 100000 /* C.MaxDistanceBeforeViewport */ &&
|
|
9896
|
+
ranges.some(r => r.from <= context.viewport.from && r.to >= context.viewport.from)) {
|
|
9780
9897
|
this.state = this.lang.streamParser.startState(getIndentUnit(context.state));
|
|
9781
9898
|
context.skipUntilInView(this.parsedPos, context.viewport.from);
|
|
9782
9899
|
this.parsedPos = context.viewport.from;
|
|
@@ -9847,7 +9964,8 @@ class Parse {
|
|
|
9847
9964
|
while (this.ranges[this.rangeIndex].to < this.parsedPos)
|
|
9848
9965
|
this.rangeIndex++;
|
|
9849
9966
|
}
|
|
9850
|
-
emitToken(id, from, to,
|
|
9967
|
+
emitToken(id, from, to, offset) {
|
|
9968
|
+
let size = 4;
|
|
9851
9969
|
if (this.ranges.length > 1) {
|
|
9852
9970
|
offset = this.skipGapsTo(from, offset, 1);
|
|
9853
9971
|
from += offset;
|
|
@@ -9856,7 +9974,11 @@ class Parse {
|
|
|
9856
9974
|
to += offset;
|
|
9857
9975
|
size += this.chunk.length - len0;
|
|
9858
9976
|
}
|
|
9859
|
-
this.chunk.
|
|
9977
|
+
let last = this.chunk.length - 4;
|
|
9978
|
+
if (size == 4 && last >= 0 && this.chunk[last] == id && this.chunk[last + 2] == from)
|
|
9979
|
+
this.chunk[last + 2] = to;
|
|
9980
|
+
else
|
|
9981
|
+
this.chunk.push(id, from, to, size);
|
|
9860
9982
|
return offset;
|
|
9861
9983
|
}
|
|
9862
9984
|
parseLine(context) {
|
|
@@ -9869,7 +9991,7 @@ class Parse {
|
|
|
9869
9991
|
while (!stream.eol()) {
|
|
9870
9992
|
let token = readToken(streamParser.token, stream, this.state);
|
|
9871
9993
|
if (token)
|
|
9872
|
-
offset = this.emitToken(this.lang.tokenTable.resolve(token), this.parsedPos + stream.start, this.parsedPos + stream.pos,
|
|
9994
|
+
offset = this.emitToken(this.lang.tokenTable.resolve(token), this.parsedPos + stream.start, this.parsedPos + stream.pos, offset);
|
|
9873
9995
|
if (stream.start > 10000 /* C.MaxLineLength */)
|
|
9874
9996
|
break;
|
|
9875
9997
|
}
|
|
@@ -9986,8 +10108,11 @@ function createTokenType(extra, tagStr) {
|
|
|
9986
10108
|
typeArray.push(type);
|
|
9987
10109
|
return type.id;
|
|
9988
10110
|
}
|
|
9989
|
-
function docID(data) {
|
|
9990
|
-
let type = dist/* NodeType */.Z6.define({ id: typeArray.length, name: "Document", props: [
|
|
10111
|
+
function docID(data, lang) {
|
|
10112
|
+
let type = dist/* NodeType */.Z6.define({ id: typeArray.length, name: "Document", props: [
|
|
10113
|
+
languageDataProp.add(() => data),
|
|
10114
|
+
indentNodeProp.add(() => cx => lang.getIndent(cx))
|
|
10115
|
+
], top: true });
|
|
9991
10116
|
typeArray.push(type);
|
|
9992
10117
|
return type;
|
|
9993
10118
|
}
|
|
@@ -12368,37 +12493,37 @@ function enterFragments(mounts, ranges) {
|
|
|
12368
12493
|
var __webpack_exports__ = {};
|
|
12369
12494
|
__webpack_require__.r(__webpack_exports__);
|
|
12370
12495
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
12371
|
-
/* harmony export */ basicSetup: () => (/* reexport safe */
|
|
12372
|
-
/* harmony export */ "default": () => (
|
|
12373
|
-
/* harmony export */ getStatistics: () => (/* reexport safe */
|
|
12374
|
-
/* harmony export */ minimalSetup: () => (/* reexport safe */
|
|
12375
|
-
/* harmony export */ useCodeMirror: () => (/* reexport safe */
|
|
12496
|
+
/* harmony export */ basicSetup: () => (/* reexport safe */ src_uiw_codemirror_extensions_basic_setup_WEBPACK_IMPORTED_MODULE_5_.o),
|
|
12497
|
+
/* harmony export */ "default": () => (src),
|
|
12498
|
+
/* harmony export */ getStatistics: () => (/* reexport safe */ src_utils_WEBPACK_IMPORTED_MODULE_7_.m),
|
|
12499
|
+
/* harmony export */ minimalSetup: () => (/* reexport safe */ src_uiw_codemirror_extensions_basic_setup_WEBPACK_IMPORTED_MODULE_5_.V),
|
|
12500
|
+
/* harmony export */ useCodeMirror: () => (/* reexport safe */ src_useCodeMirror_WEBPACK_IMPORTED_MODULE_1_.q)
|
|
12376
12501
|
/* harmony export */ });
|
|
12377
|
-
/* harmony import */ var
|
|
12378
|
-
/* harmony import */ var
|
|
12379
|
-
/* harmony import */ var
|
|
12380
|
-
/* harmony import */ var
|
|
12381
|
-
/* harmony import */ var
|
|
12382
|
-
/* harmony import */ var
|
|
12383
|
-
/* harmony import */ var
|
|
12384
|
-
/* harmony import */ var
|
|
12385
|
-
/* harmony import */ var
|
|
12386
|
-
/* harmony reexport (unknown) */ var
|
|
12387
|
-
/* harmony reexport (unknown) */ for(const __WEBPACK_IMPORT_KEY__ in
|
|
12388
|
-
/* harmony reexport (unknown) */ __webpack_require__.d(__webpack_exports__,
|
|
12389
|
-
/* harmony import */ var
|
|
12390
|
-
/* harmony import */ var
|
|
12391
|
-
/* harmony reexport (unknown) */ var
|
|
12392
|
-
/* harmony reexport (unknown) */ for(const __WEBPACK_IMPORT_KEY__ in
|
|
12393
|
-
/* harmony reexport (unknown) */ __webpack_require__.d(__webpack_exports__,
|
|
12394
|
-
/* harmony import */ var
|
|
12395
|
-
/* harmony import */ var
|
|
12396
|
-
/* harmony reexport (unknown) */ var
|
|
12397
|
-
/* harmony reexport (unknown) */ for(const __WEBPACK_IMPORT_KEY__ in
|
|
12398
|
-
/* harmony reexport (unknown) */ __webpack_require__.d(__webpack_exports__,
|
|
12399
|
-
/* harmony import */ var
|
|
12400
|
-
var
|
|
12401
|
-
if(typeof value!=='string'){throw new Error("value must be typeof string but got ".concat(typeof value));}var defaultClassNames=typeof theme==='string'?"cm-theme-".concat(theme):'cm-theme';return/*#__PURE__*/(0,
|
|
12502
|
+
/* harmony import */ var src_home_runner_work_react_codemirror_react_codemirror_node_modules_babel_runtime_helpers_esm_objectSpread2_js_WEBPACK_IMPORTED_MODULE_9_ = __webpack_require__(957);
|
|
12503
|
+
/* harmony import */ var src_home_runner_work_react_codemirror_react_codemirror_node_modules_babel_runtime_helpers_esm_objectWithoutProperties_js_WEBPACK_IMPORTED_MODULE_8_ = __webpack_require__(644);
|
|
12504
|
+
/* harmony import */ var src_react_WEBPACK_IMPORTED_MODULE_0_ = __webpack_require__(442);
|
|
12505
|
+
/* harmony import */ var src_react_WEBPACK_IMPORTED_MODULE_0_default = /*#__PURE__*/__webpack_require__.n(src_react_WEBPACK_IMPORTED_MODULE_0_);
|
|
12506
|
+
/* harmony import */ var src_useCodeMirror_WEBPACK_IMPORTED_MODULE_1_ = __webpack_require__(695);
|
|
12507
|
+
/* harmony import */ var src_react_jsx_runtime_WEBPACK_IMPORTED_MODULE_2_ = __webpack_require__(742);
|
|
12508
|
+
/* harmony import */ var src_react_jsx_runtime_WEBPACK_IMPORTED_MODULE_2_default = /*#__PURE__*/__webpack_require__.n(src_react_jsx_runtime_WEBPACK_IMPORTED_MODULE_2_);
|
|
12509
|
+
/* harmony import */ var src_codemirror_view_WEBPACK_IMPORTED_MODULE_3_ = __webpack_require__(730);
|
|
12510
|
+
/* harmony import */ var src_codemirror_view_WEBPACK_IMPORTED_MODULE_3_default = /*#__PURE__*/__webpack_require__.n(src_codemirror_view_WEBPACK_IMPORTED_MODULE_3_);
|
|
12511
|
+
/* harmony reexport (unknown) */ var src_WEBPACK_REEXPORT_OBJECT_ = {};
|
|
12512
|
+
/* harmony reexport (unknown) */ for(const __WEBPACK_IMPORT_KEY__ in src_codemirror_view_WEBPACK_IMPORTED_MODULE_3_) if(__WEBPACK_IMPORT_KEY__ !== "default") src_WEBPACK_REEXPORT_OBJECT_[__WEBPACK_IMPORT_KEY__] = () => src_codemirror_view_WEBPACK_IMPORTED_MODULE_3_[__WEBPACK_IMPORT_KEY__]
|
|
12513
|
+
/* harmony reexport (unknown) */ __webpack_require__.d(__webpack_exports__, src_WEBPACK_REEXPORT_OBJECT_);
|
|
12514
|
+
/* harmony import */ var src_codemirror_state_WEBPACK_IMPORTED_MODULE_4_ = __webpack_require__(60);
|
|
12515
|
+
/* harmony import */ var src_codemirror_state_WEBPACK_IMPORTED_MODULE_4_default = /*#__PURE__*/__webpack_require__.n(src_codemirror_state_WEBPACK_IMPORTED_MODULE_4_);
|
|
12516
|
+
/* harmony reexport (unknown) */ var src_WEBPACK_REEXPORT_OBJECT_ = {};
|
|
12517
|
+
/* harmony reexport (unknown) */ for(const __WEBPACK_IMPORT_KEY__ in src_codemirror_state_WEBPACK_IMPORTED_MODULE_4_) if(__WEBPACK_IMPORT_KEY__ !== "default") src_WEBPACK_REEXPORT_OBJECT_[__WEBPACK_IMPORT_KEY__] = () => src_codemirror_state_WEBPACK_IMPORTED_MODULE_4_[__WEBPACK_IMPORT_KEY__]
|
|
12518
|
+
/* harmony reexport (unknown) */ __webpack_require__.d(__webpack_exports__, src_WEBPACK_REEXPORT_OBJECT_);
|
|
12519
|
+
/* harmony import */ var src_uiw_codemirror_extensions_basic_setup_WEBPACK_IMPORTED_MODULE_5_ = __webpack_require__(368);
|
|
12520
|
+
/* harmony import */ var src_getDefaultExtensions_WEBPACK_IMPORTED_MODULE_6_ = __webpack_require__(89);
|
|
12521
|
+
/* harmony reexport (unknown) */ var src_WEBPACK_REEXPORT_OBJECT_ = {};
|
|
12522
|
+
/* harmony reexport (unknown) */ for(const __WEBPACK_IMPORT_KEY__ in src_getDefaultExtensions_WEBPACK_IMPORTED_MODULE_6_) if(["default","basicSetup","minimalSetup","useCodeMirror"].indexOf(__WEBPACK_IMPORT_KEY__) < 0) src_WEBPACK_REEXPORT_OBJECT_[__WEBPACK_IMPORT_KEY__] = () => src_getDefaultExtensions_WEBPACK_IMPORTED_MODULE_6_[__WEBPACK_IMPORT_KEY__]
|
|
12523
|
+
/* harmony reexport (unknown) */ __webpack_require__.d(__webpack_exports__, src_WEBPACK_REEXPORT_OBJECT_);
|
|
12524
|
+
/* harmony import */ var src_utils_WEBPACK_IMPORTED_MODULE_7_ = __webpack_require__(369);
|
|
12525
|
+
var src_excluded=["className","value","selection","extensions","onChange","onStatistics","onCreateEditor","onUpdate","autoFocus","theme","height","minHeight","maxHeight","width","minWidth","maxWidth","basicSetup","placeholder","indentWithTab","editable","readOnly","root","initialState"];var src_ReactCodeMirror=/*#__PURE__*/(0,src_react_WEBPACK_IMPORTED_MODULE_0_.forwardRef)(function(props,ref){var className=props.className,_props$value=props.value,value=_props$value===void 0?'':_props$value,selection=props.selection,_props$extensions=props.extensions,extensions=_props$extensions===void 0?[]:_props$extensions,onChange=props.onChange,onStatistics=props.onStatistics,onCreateEditor=props.onCreateEditor,onUpdate=props.onUpdate,autoFocus=props.autoFocus,_props$theme=props.theme,theme=_props$theme===void 0?'light':_props$theme,height=props.height,minHeight=props.minHeight,maxHeight=props.maxHeight,width=props.width,minWidth=props.minWidth,maxWidth=props.maxWidth,basicSetup=props.basicSetup,placeholder=props.placeholder,indentWithTab=props.indentWithTab,editable=props.editable,readOnly=props.readOnly,root=props.root,initialState=props.initialState,other=(0,src_home_runner_work_react_codemirror_react_codemirror_node_modules_babel_runtime_helpers_esm_objectWithoutProperties_js_WEBPACK_IMPORTED_MODULE_8_/* ["default"] */ .A)(props,src_excluded);var editor=(0,src_react_WEBPACK_IMPORTED_MODULE_0_.useRef)(null);var _useCodeMirror=(0,src_useCodeMirror_WEBPACK_IMPORTED_MODULE_1_/* .useCodeMirror */ .q)({container:editor.current,root:root,value:value,autoFocus:autoFocus,theme:theme,height:height,minHeight:minHeight,maxHeight:maxHeight,width:width,minWidth:minWidth,maxWidth:maxWidth,basicSetup:basicSetup,placeholder:placeholder,indentWithTab:indentWithTab,editable:editable,readOnly:readOnly,selection:selection,onChange:onChange,onStatistics:onStatistics,onCreateEditor:onCreateEditor,onUpdate:onUpdate,extensions:extensions,initialState:initialState}),state=_useCodeMirror.state,view=_useCodeMirror.view,container=_useCodeMirror.container;(0,src_react_WEBPACK_IMPORTED_MODULE_0_.useImperativeHandle)(ref,function(){return{editor:editor.current,state:state,view:view};},[editor,container,state,view]);// check type of value
|
|
12526
|
+
if(typeof value!=='string'){throw new Error("value must be typeof string but got ".concat(typeof value));}var defaultClassNames=typeof theme==='string'?"cm-theme-".concat(theme):'cm-theme';return/*#__PURE__*/(0,src_react_jsx_runtime_WEBPACK_IMPORTED_MODULE_2_.jsx)("div",(0,src_home_runner_work_react_codemirror_react_codemirror_node_modules_babel_runtime_helpers_esm_objectSpread2_js_WEBPACK_IMPORTED_MODULE_9_/* ["default"] */ .A)({ref:editor,className:"".concat(defaultClassNames).concat(className?" ".concat(className):'')},other));});src_ReactCodeMirror.displayName='CodeMirror';/* harmony default export */ const src = (src_ReactCodeMirror);
|
|
12402
12527
|
/******/ return __webpack_exports__;
|
|
12403
12528
|
/******/ })()
|
|
12404
12529
|
;
|