[mod] highlightWhitespace
This commit is contained in:
parent
55fef63678
commit
be12f0200c
7 changed files with 347 additions and 338 deletions
|
|
@ -210,6 +210,10 @@
|
|||
<input name="wrapLines" type="checkbox" class="form-check-input" id="lineWrap">
|
||||
<label class="form-check-label" for="lineWrap">Wrap lines</label>
|
||||
</div>
|
||||
<div class="mb-3 form-check">
|
||||
<input name="highlightWhitespace" type="checkbox" class="form-check-input" id="highlightWhitespace">
|
||||
<label class="form-check-label" for="highlightWhitespace">highlight Whitespace</label>
|
||||
</div>
|
||||
<div class="mb-3 form-check">
|
||||
<input name="minimap" type="checkbox" class="form-check-input" id="minimap">
|
||||
<label class="form-check-label" for="minimap">Show minimap</label>
|
||||
|
|
|
|||
|
|
@ -4281,6 +4281,35 @@ var lsp = (function (exports) {
|
|||
}
|
||||
}
|
||||
|
||||
let nav = typeof navigator != "undefined" ? navigator : { userAgent: "", vendor: "", platform: "" };
|
||||
let doc = typeof document != "undefined" ? document : { documentElement: { style: {} } };
|
||||
const ie_edge = /*@__PURE__*//Edge\/(\d+)/.exec(nav.userAgent);
|
||||
const ie_upto10 = /*@__PURE__*//MSIE \d/.test(nav.userAgent);
|
||||
const ie_11up = /*@__PURE__*//Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nav.userAgent);
|
||||
const ie = !!(ie_upto10 || ie_11up || ie_edge);
|
||||
const gecko = !ie && /*@__PURE__*//gecko\/(\d+)/i.test(nav.userAgent);
|
||||
const chrome = !ie && /*@__PURE__*//Chrome\/(\d+)/.exec(nav.userAgent);
|
||||
const webkit = "webkitFontSmoothing" in doc.documentElement.style;
|
||||
const safari = !ie && /*@__PURE__*//Apple Computer/.test(nav.vendor);
|
||||
const ios = safari && (/*@__PURE__*//Mobile\/\w+/.test(nav.userAgent) || nav.maxTouchPoints > 2);
|
||||
var browser = {
|
||||
mac: ios || /*@__PURE__*//Mac/.test(nav.platform),
|
||||
windows: /*@__PURE__*//Win/.test(nav.platform),
|
||||
linux: /*@__PURE__*//Linux|X11/.test(nav.platform),
|
||||
ie,
|
||||
ie_version: ie_upto10 ? doc.documentMode || 6 : ie_11up ? +ie_11up[1] : ie_edge ? +ie_edge[1] : 0,
|
||||
gecko,
|
||||
gecko_version: gecko ? +(/*@__PURE__*//Firefox\/(\d+)/.exec(nav.userAgent) || [0, 0])[1] : 0,
|
||||
chrome: !!chrome,
|
||||
chrome_version: chrome ? +chrome[1] : 0,
|
||||
ios,
|
||||
android: /*@__PURE__*//Android\b/.test(nav.userAgent),
|
||||
webkit_version: webkit ? +(/*@__PURE__*//\bAppleWebKit\/(\d+)/.exec(nav.userAgent) || [0, 0])[1] : 0,
|
||||
safari,
|
||||
safari_version: safari ? +(/*@__PURE__*//\bVersion\/(\d+(\.\d+)?)/.exec(nav.userAgent) || [0, 0])[1] : 0,
|
||||
tabSize: doc.documentElement.style.tabSize != null ? "tab-size" : "-moz-tab-size"
|
||||
};
|
||||
|
||||
function getSelection(root) {
|
||||
let target;
|
||||
// Browsers differ on whether shadow roots have a getSelection
|
||||
|
|
@ -4531,6 +4560,9 @@ var lsp = (function (exports) {
|
|||
}
|
||||
}
|
||||
let preventScrollSupported = null;
|
||||
// Safari 26 breaks preventScroll support
|
||||
if (browser.safari && browser.safari_version >= 26)
|
||||
preventScrollSupported = false;
|
||||
// Feature-detects support for .focus({preventScroll: true}), and uses
|
||||
// a fallback kludge when not supported.
|
||||
function focusPreventScroll(dom) {
|
||||
|
|
@ -5000,34 +5032,6 @@ var lsp = (function (exports) {
|
|||
replaceRange(parent, fromI, fromOff, toI, toOff, insert, 0, openStart, openEnd);
|
||||
}
|
||||
|
||||
let nav = typeof navigator != "undefined" ? navigator : { userAgent: "", vendor: "", platform: "" };
|
||||
let doc = typeof document != "undefined" ? document : { documentElement: { style: {} } };
|
||||
const ie_edge = /*@__PURE__*//Edge\/(\d+)/.exec(nav.userAgent);
|
||||
const ie_upto10 = /*@__PURE__*//MSIE \d/.test(nav.userAgent);
|
||||
const ie_11up = /*@__PURE__*//Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(nav.userAgent);
|
||||
const ie = !!(ie_upto10 || ie_11up || ie_edge);
|
||||
const gecko = !ie && /*@__PURE__*//gecko\/(\d+)/i.test(nav.userAgent);
|
||||
const chrome = !ie && /*@__PURE__*//Chrome\/(\d+)/.exec(nav.userAgent);
|
||||
const webkit = "webkitFontSmoothing" in doc.documentElement.style;
|
||||
const safari = !ie && /*@__PURE__*//Apple Computer/.test(nav.vendor);
|
||||
const ios = safari && (/*@__PURE__*//Mobile\/\w+/.test(nav.userAgent) || nav.maxTouchPoints > 2);
|
||||
var browser = {
|
||||
mac: ios || /*@__PURE__*//Mac/.test(nav.platform),
|
||||
windows: /*@__PURE__*//Win/.test(nav.platform),
|
||||
linux: /*@__PURE__*//Linux|X11/.test(nav.platform),
|
||||
ie,
|
||||
ie_version: ie_upto10 ? doc.documentMode || 6 : ie_11up ? +ie_11up[1] : ie_edge ? +ie_edge[1] : 0,
|
||||
gecko,
|
||||
gecko_version: gecko ? +(/*@__PURE__*//Firefox\/(\d+)/.exec(nav.userAgent) || [0, 0])[1] : 0,
|
||||
chrome: !!chrome,
|
||||
chrome_version: chrome ? +chrome[1] : 0,
|
||||
ios,
|
||||
android: /*@__PURE__*//Android\b/.test(nav.userAgent),
|
||||
safari,
|
||||
webkit_version: webkit ? +(/*@__PURE__*//\bAppleWebKit\/(\d+)/.exec(nav.userAgent) || [0, 0])[1] : 0,
|
||||
tabSize: doc.documentElement.style.tabSize != null ? "tab-size" : "-moz-tab-size"
|
||||
};
|
||||
|
||||
const MaxJoinLen = 256;
|
||||
class TextView extends ContentView {
|
||||
constructor(text) {
|
||||
|
|
@ -8131,9 +8135,10 @@ var lsp = (function (exports) {
|
|||
if (next == end)
|
||||
break;
|
||||
let view = ContentView.get(cur), nextView = ContentView.get(next);
|
||||
if (view && nextView ? view.breakAfter :
|
||||
if ((view && nextView ? view.breakAfter :
|
||||
(view ? view.breakAfter : isBlockElement(cur)) ||
|
||||
(isBlockElement(next) && (cur.nodeName != "BR" || cur.cmIgnore) && this.text.length > oldLen))
|
||||
(isBlockElement(next) && (cur.nodeName != "BR" || cur.cmIgnore) && this.text.length > oldLen)) &&
|
||||
!isEmptyToEnd(next, end))
|
||||
this.lineBreak();
|
||||
cur = next;
|
||||
}
|
||||
|
|
@ -8212,6 +8217,25 @@ var lsp = (function (exports) {
|
|||
node = node.parentNode;
|
||||
}
|
||||
}
|
||||
function isEmptyToEnd(node, end) {
|
||||
let widgets;
|
||||
for (;; node = node.nextSibling) {
|
||||
if (node == end || !node)
|
||||
break;
|
||||
let view = ContentView.get(node);
|
||||
if (!((view === null || view === void 0 ? void 0 : view.isWidget) || node.cmIgnore))
|
||||
return false;
|
||||
if (view)
|
||||
(widgets || (widgets = [])).push(view);
|
||||
}
|
||||
if (widgets)
|
||||
for (let w of widgets) {
|
||||
let override = w.overrideDOMText;
|
||||
if (override === null || override === void 0 ? void 0 : override.length)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
class DOMPoint {
|
||||
constructor(node, offset) {
|
||||
this.node = node;
|
||||
|
|
@ -8653,7 +8677,7 @@ var lsp = (function (exports) {
|
|||
return dispatchKey(this.view.contentDOM, key.key, key.keyCode, key instanceof KeyboardEvent ? key : undefined);
|
||||
}
|
||||
ignoreDuringComposition(event) {
|
||||
if (!/^key/.test(event.type))
|
||||
if (!/^key/.test(event.type) || event.synthetic)
|
||||
return false;
|
||||
if (this.composing > 0)
|
||||
return true;
|
||||
|
|
@ -11557,20 +11581,23 @@ var lsp = (function (exports) {
|
|||
let from = this.toEditorPos(e.updateRangeStart), to = this.toEditorPos(e.updateRangeEnd);
|
||||
if (view.inputState.composing >= 0 && !this.composing)
|
||||
this.composing = { contextBase: e.updateRangeStart, editorBase: from, drifted: false };
|
||||
let change = { from, to, insert: Text.of(e.text.split("\n")) };
|
||||
let deletes = to - from > e.text.length;
|
||||
// If the window doesn't include the anchor, assume changes
|
||||
// adjacent to a side go up to the anchor.
|
||||
if (change.from == this.from && anchor < this.from)
|
||||
change.from = anchor;
|
||||
else if (change.to == this.to && anchor > this.to)
|
||||
change.to = anchor;
|
||||
if (from == this.from && anchor < this.from)
|
||||
from = anchor;
|
||||
else if (to == this.to && anchor > this.to)
|
||||
to = anchor;
|
||||
let diff = findDiff(view.state.sliceDoc(from, to), e.text, (deletes ? main.from : main.to) - from, deletes ? "end" : null);
|
||||
// Edit contexts sometimes fire empty changes
|
||||
if (change.from == change.to && !change.insert.length) {
|
||||
if (!diff) {
|
||||
let newSel = EditorSelection.single(this.toEditorPos(e.selectionStart), this.toEditorPos(e.selectionEnd));
|
||||
if (!newSel.main.eq(main))
|
||||
view.dispatch({ selection: newSel, userEvent: "select" });
|
||||
return;
|
||||
}
|
||||
let change = { from: diff.from + from, to: diff.toA + from,
|
||||
insert: Text.of(e.text.slice(diff.from, diff.toB).split("\n")) };
|
||||
if ((browser.mac || browser.android) && change.from == head - 1 &&
|
||||
/^\. ?$/.test(e.text) && view.contentDOM.getAttribute("autocorrect") == "off")
|
||||
change = { from, to, insert: Text.of([e.text.replace(".", " ")]) };
|
||||
|
|
@ -11585,6 +11612,10 @@ var lsp = (function (exports) {
|
|||
this.revertPending(view.state);
|
||||
this.setSelection(view.state);
|
||||
}
|
||||
// Work around missed compositionend events. See https://discuss.codemirror.net/t/a/9514
|
||||
if (change.from < change.to && !change.insert.length && view.inputState.composing >= 0 &&
|
||||
!/[\\p{Alphabetic}\\p{Number}_]/.test(context.text.slice(Math.max(0, e.updateRangeStart - 1), Math.min(context.text.length, e.updateRangeStart + 1))))
|
||||
this.handlers.compositionend(e);
|
||||
};
|
||||
this.handlers.characterboundsupdate = e => {
|
||||
let rects = [], prev = null;
|
||||
|
|
@ -11600,10 +11631,11 @@ var lsp = (function (exports) {
|
|||
let deco = [];
|
||||
for (let format of e.getTextFormats()) {
|
||||
let lineStyle = format.underlineStyle, thickness = format.underlineThickness;
|
||||
if (lineStyle != "None" && thickness != "None") {
|
||||
if (!/none/i.test(lineStyle) && !/none/i.test(thickness)) {
|
||||
let from = this.toEditorPos(format.rangeStart), to = this.toEditorPos(format.rangeEnd);
|
||||
if (from < to) {
|
||||
let style = `text-decoration: underline ${lineStyle == "Dashed" ? "dashed " : lineStyle == "Squiggle" ? "wavy " : ""}${thickness == "Thin" ? 1 : 2}px`;
|
||||
// These values changed from capitalized custom strings to lower-case CSS keywords in 2025
|
||||
let style = `text-decoration: underline ${/^[a-z]/.test(lineStyle) ? lineStyle + " " : lineStyle == "Dashed" ? "dashed " : lineStyle == "Squiggle" ? "wavy " : ""}${/thin/i.test(thickness) ? 1 : 2}px`;
|
||||
deco.push(Decoration.mark({ attributes: { style } }).range(from, to));
|
||||
}
|
||||
}
|
||||
|
|
@ -13370,7 +13402,7 @@ var lsp = (function (exports) {
|
|||
old = next;
|
||||
}
|
||||
this.drawn = markers;
|
||||
if (browser.ios) // Issue #1600
|
||||
if (browser.safari && browser.safari_version >= 26) // Issue #1600, 1627
|
||||
this.dom.style.display = this.dom.firstChild ? "" : "none";
|
||||
}
|
||||
}
|
||||
|
|
@ -13709,156 +13741,6 @@ var lsp = (function (exports) {
|
|||
}
|
||||
}
|
||||
|
||||
const UnicodeRegexpSupport = /x/.unicode != null ? "gu" : "g";
|
||||
const Specials = /*@__PURE__*/new RegExp("[\u0000-\u0008\u000a-\u001f\u007f-\u009f\u00ad\u061c\u200b\u200e\u200f\u2028\u2029\u202d\u202e\u2066\u2067\u2069\ufeff\ufff9-\ufffc]", UnicodeRegexpSupport);
|
||||
const Names = {
|
||||
0: "null",
|
||||
7: "bell",
|
||||
8: "backspace",
|
||||
10: "newline",
|
||||
11: "vertical tab",
|
||||
13: "carriage return",
|
||||
27: "escape",
|
||||
8203: "zero width space",
|
||||
8204: "zero width non-joiner",
|
||||
8205: "zero width joiner",
|
||||
8206: "left-to-right mark",
|
||||
8207: "right-to-left mark",
|
||||
8232: "line separator",
|
||||
8237: "left-to-right override",
|
||||
8238: "right-to-left override",
|
||||
8294: "left-to-right isolate",
|
||||
8295: "right-to-left isolate",
|
||||
8297: "pop directional isolate",
|
||||
8233: "paragraph separator",
|
||||
65279: "zero width no-break space",
|
||||
65532: "object replacement"
|
||||
};
|
||||
let _supportsTabSize = null;
|
||||
function supportsTabSize() {
|
||||
var _a;
|
||||
if (_supportsTabSize == null && typeof document != "undefined" && document.body) {
|
||||
let styles = document.body.style;
|
||||
_supportsTabSize = ((_a = styles.tabSize) !== null && _a !== void 0 ? _a : styles.MozTabSize) != null;
|
||||
}
|
||||
return _supportsTabSize || false;
|
||||
}
|
||||
const specialCharConfig = /*@__PURE__*/Facet.define({
|
||||
combine(configs) {
|
||||
let config = combineConfig(configs, {
|
||||
render: null,
|
||||
specialChars: Specials,
|
||||
addSpecialChars: null
|
||||
});
|
||||
if (config.replaceTabs = !supportsTabSize())
|
||||
config.specialChars = new RegExp("\t|" + config.specialChars.source, UnicodeRegexpSupport);
|
||||
if (config.addSpecialChars)
|
||||
config.specialChars = new RegExp(config.specialChars.source + "|" + config.addSpecialChars.source, UnicodeRegexpSupport);
|
||||
return config;
|
||||
}
|
||||
});
|
||||
/**
|
||||
Returns an extension that installs highlighting of special
|
||||
characters.
|
||||
*/
|
||||
function highlightSpecialChars(
|
||||
/**
|
||||
Configuration options.
|
||||
*/
|
||||
config = {}) {
|
||||
return [specialCharConfig.of(config), specialCharPlugin()];
|
||||
}
|
||||
let _plugin = null;
|
||||
function specialCharPlugin() {
|
||||
return _plugin || (_plugin = ViewPlugin.fromClass(class {
|
||||
constructor(view) {
|
||||
this.view = view;
|
||||
this.decorations = Decoration.none;
|
||||
this.decorationCache = Object.create(null);
|
||||
this.decorator = this.makeDecorator(view.state.facet(specialCharConfig));
|
||||
this.decorations = this.decorator.createDeco(view);
|
||||
}
|
||||
makeDecorator(conf) {
|
||||
return new MatchDecorator({
|
||||
regexp: conf.specialChars,
|
||||
decoration: (m, view, pos) => {
|
||||
let { doc } = view.state;
|
||||
let code = codePointAt(m[0], 0);
|
||||
if (code == 9) {
|
||||
let line = doc.lineAt(pos);
|
||||
let size = view.state.tabSize, col = countColumn(line.text, size, pos - line.from);
|
||||
return Decoration.replace({
|
||||
widget: new TabWidget((size - (col % size)) * this.view.defaultCharacterWidth / this.view.scaleX)
|
||||
});
|
||||
}
|
||||
return this.decorationCache[code] ||
|
||||
(this.decorationCache[code] = Decoration.replace({ widget: new SpecialCharWidget(conf, code) }));
|
||||
},
|
||||
boundary: conf.replaceTabs ? undefined : /[^]/
|
||||
});
|
||||
}
|
||||
update(update) {
|
||||
let conf = update.state.facet(specialCharConfig);
|
||||
if (update.startState.facet(specialCharConfig) != conf) {
|
||||
this.decorator = this.makeDecorator(conf);
|
||||
this.decorations = this.decorator.createDeco(update.view);
|
||||
}
|
||||
else {
|
||||
this.decorations = this.decorator.updateDeco(update, this.decorations);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
decorations: v => v.decorations
|
||||
}));
|
||||
}
|
||||
const DefaultPlaceholder = "\u2022";
|
||||
// Assigns placeholder characters from the Control Pictures block to
|
||||
// ASCII control characters
|
||||
function placeholder$1(code) {
|
||||
if (code >= 32)
|
||||
return DefaultPlaceholder;
|
||||
if (code == 10)
|
||||
return "\u2424";
|
||||
return String.fromCharCode(9216 + code);
|
||||
}
|
||||
class SpecialCharWidget extends WidgetType {
|
||||
constructor(options, code) {
|
||||
super();
|
||||
this.options = options;
|
||||
this.code = code;
|
||||
}
|
||||
eq(other) { return other.code == this.code; }
|
||||
toDOM(view) {
|
||||
let ph = placeholder$1(this.code);
|
||||
let desc = view.state.phrase("Control character") + " " + (Names[this.code] || "0x" + this.code.toString(16));
|
||||
let custom = this.options.render && this.options.render(this.code, desc, ph);
|
||||
if (custom)
|
||||
return custom;
|
||||
let span = document.createElement("span");
|
||||
span.textContent = ph;
|
||||
span.title = desc;
|
||||
span.setAttribute("aria-label", desc);
|
||||
span.className = "cm-specialChar";
|
||||
return span;
|
||||
}
|
||||
ignoreEvent() { return false; }
|
||||
}
|
||||
class TabWidget extends WidgetType {
|
||||
constructor(width) {
|
||||
super();
|
||||
this.width = width;
|
||||
}
|
||||
eq(other) { return other.width == this.width; }
|
||||
toDOM() {
|
||||
let span = document.createElement("span");
|
||||
span.textContent = "\t";
|
||||
span.className = "cm-tab";
|
||||
span.style.width = this.width + "px";
|
||||
return span;
|
||||
}
|
||||
ignoreEvent() { return false; }
|
||||
}
|
||||
|
||||
/**
|
||||
Mark lines that have a cursor on them with the `"cm-activeLine"`
|
||||
DOM class.
|
||||
|
|
@ -15526,6 +15408,33 @@ var lsp = (function (exports) {
|
|||
return activeLineGutterHighlighter;
|
||||
}
|
||||
|
||||
function matcher(decorator) {
|
||||
return ViewPlugin.define(view => ({
|
||||
decorations: decorator.createDeco(view),
|
||||
update(u) {
|
||||
this.decorations = decorator.updateDeco(u, this.decorations);
|
||||
},
|
||||
}), {
|
||||
decorations: v => v.decorations
|
||||
});
|
||||
}
|
||||
const tabDeco = /*@__PURE__*/Decoration.mark({ class: "cm-highlightTab" });
|
||||
const spaceDeco = /*@__PURE__*/Decoration.mark({ class: "cm-highlightSpace" });
|
||||
const whitespaceHighlighter = /*@__PURE__*/matcher(/*@__PURE__*/new MatchDecorator({
|
||||
regexp: /\t| /g,
|
||||
decoration: match => match[0] == "\t" ? tabDeco : spaceDeco,
|
||||
boundary: /\S/,
|
||||
}));
|
||||
/**
|
||||
Returns an extension that highlights whitespace, adding a
|
||||
`cm-highlightSpace` class to stretches of spaces, and a
|
||||
`cm-highlightTab` class to individual tab characters. By default,
|
||||
the former are shown as faint dots, and the latter as arrows.
|
||||
*/
|
||||
function highlightWhitespace() {
|
||||
return whitespaceHighlighter;
|
||||
}
|
||||
|
||||
const basicNormalize = typeof String.prototype.normalize == "function"
|
||||
? x => x.normalize("NFKD") : x => x;
|
||||
/**
|
||||
|
|
@ -17040,22 +16949,36 @@ var lsp = (function (exports) {
|
|||
}
|
||||
const lintConfig = /*@__PURE__*/Facet.define({
|
||||
combine(input) {
|
||||
return Object.assign({ sources: input.map(i => i.source).filter(x => x != null) }, combineConfig(input.map(i => i.config), {
|
||||
delay: 750,
|
||||
markerFilter: null,
|
||||
tooltipFilter: null,
|
||||
needsRefresh: null,
|
||||
hideOn: () => null,
|
||||
}, {
|
||||
needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u)
|
||||
}));
|
||||
return {
|
||||
sources: input.map(i => i.source).filter(x => x != null),
|
||||
...combineConfig(input.map(i => i.config), {
|
||||
delay: 750,
|
||||
markerFilter: null,
|
||||
tooltipFilter: null,
|
||||
needsRefresh: null,
|
||||
hideOn: () => null,
|
||||
}, {
|
||||
delay: Math.max,
|
||||
markerFilter: combineFilter,
|
||||
tooltipFilter: combineFilter,
|
||||
needsRefresh: (a, b) => !a ? b : !b ? a : u => a(u) || b(u),
|
||||
hideOn: (a, b) => !a ? b : !b ? a : (t, x, y) => a(t, x, y) || b(t, x, y),
|
||||
autoPanel: (a, b) => a || b
|
||||
})
|
||||
};
|
||||
}
|
||||
});
|
||||
function combineFilter(a, b) {
|
||||
return !a ? b : !b ? a : (d, s) => b(a(d, s), s);
|
||||
}
|
||||
/**
|
||||
Given a diagnostic source, this function returns an extension that
|
||||
enables linting with that source. It will be called whenever the
|
||||
editor is idle (after its content changed). If `null` is given as
|
||||
source, this only configures the lint extension.
|
||||
editor is idle (after its content changed).
|
||||
|
||||
Note that settings given here will apply to all linters active in
|
||||
the editor. If `null` is given as source, this only configures the
|
||||
lint extension.
|
||||
*/
|
||||
function linter(source, config = {}) {
|
||||
return [
|
||||
|
|
@ -17096,9 +17019,10 @@ var lsp = (function (exports) {
|
|||
let nameElt = keyIndex < 0 ? name : [name.slice(0, keyIndex),
|
||||
crelt("u", name.slice(keyIndex, keyIndex + 1)),
|
||||
name.slice(keyIndex + 1)];
|
||||
let markClass = action.markClass ? " " + action.markClass : "";
|
||||
return crelt("button", {
|
||||
type: "button",
|
||||
class: "cm-diagnosticAction",
|
||||
class: "cm-diagnosticAction" + markClass,
|
||||
onclick: click,
|
||||
onmousedown: click,
|
||||
"aria-label": ` Action: ${name}${keyIndex < 0 ? "" : ` (access key "${keys[i]})"`}.`
|
||||
|
|
@ -17521,7 +17445,7 @@ var lsp = (function (exports) {
|
|||
create() { return null; },
|
||||
update(tooltip, tr) {
|
||||
if (tooltip && tr.docChanged)
|
||||
tooltip = hideTooltip(tr, tooltip) ? null : Object.assign(Object.assign({}, tooltip), { pos: tr.changes.mapPos(tooltip.pos) });
|
||||
tooltip = hideTooltip(tr, tooltip) ? null : { ...tooltip, pos: tr.changes.mapPos(tooltip.pos) };
|
||||
return tr.effects.reduce((t, e) => e.is(setLintGutterTooltip) ? e.value : t, tooltip);
|
||||
},
|
||||
provide: field => showTooltip.from(field)
|
||||
|
|
@ -17631,6 +17555,7 @@ var lsp = (function (exports) {
|
|||
this.deserialize = config.deserialize || (() => {
|
||||
throw new Error("This node type doesn't define a deserialize function");
|
||||
});
|
||||
this.combine = config.combine || null;
|
||||
}
|
||||
/**
|
||||
This is meant to be used with
|
||||
|
|
@ -17895,7 +17820,10 @@ var lsp = (function (exports) {
|
|||
if (add) {
|
||||
if (!newProps)
|
||||
newProps = Object.assign({}, type.props);
|
||||
newProps[add[0].id] = add[1];
|
||||
let value = add[1], prop = add[0];
|
||||
if (prop.combine && prop.id in newProps)
|
||||
value = prop.combine(newProps[prop.id], value);
|
||||
newProps[prop.id] = value;
|
||||
}
|
||||
}
|
||||
newTypes.push(newProps ? new NodeType(type.name, newProps, type.id, type.flags) : type);
|
||||
|
|
@ -18878,7 +18806,7 @@ var lsp = (function (exports) {
|
|||
function takeNode(parentStart, minPos, children, positions, inRepeat, depth) {
|
||||
let { id, start, end, size } = cursor;
|
||||
let lookAheadAtStart = lookAhead, contextAtStart = contextHash;
|
||||
while (size < 0) {
|
||||
if (size < 0) {
|
||||
cursor.next();
|
||||
if (size == -1 /* SpecialRecord.Reuse */) {
|
||||
let node = reused[id];
|
||||
|
|
@ -19469,7 +19397,7 @@ var lsp = (function (exports) {
|
|||
For example:
|
||||
|
||||
```javascript
|
||||
parser.withProps(
|
||||
parser.configure({props: [
|
||||
styleTags({
|
||||
// Style Number and BigNumber nodes
|
||||
"Number BigNumber": tags.number,
|
||||
|
|
@ -19484,7 +19412,7 @@ var lsp = (function (exports) {
|
|||
// Style the node named "/" as punctuation
|
||||
'"/"': tags.punctuation
|
||||
})
|
||||
)
|
||||
]})
|
||||
```
|
||||
*/
|
||||
function styleTags(spec) {
|
||||
|
|
@ -19526,7 +19454,28 @@ var lsp = (function (exports) {
|
|||
}
|
||||
return ruleNodeProp.add(byName);
|
||||
}
|
||||
const ruleNodeProp = new NodeProp();
|
||||
const ruleNodeProp = new NodeProp({
|
||||
combine(a, b) {
|
||||
let cur, root, take;
|
||||
while (a || b) {
|
||||
if (!a || a.depth > b.depth) {
|
||||
take = b;
|
||||
b = b.next;
|
||||
}
|
||||
else {
|
||||
take = a;
|
||||
a = a.next;
|
||||
}
|
||||
let copy = new Rule(take.tags, take.mode, take.context);
|
||||
if (cur)
|
||||
cur.next = copy;
|
||||
else
|
||||
root = copy;
|
||||
cur = copy;
|
||||
}
|
||||
return root;
|
||||
}
|
||||
});
|
||||
class Rule {
|
||||
constructor(tags, mode, context, next) {
|
||||
this.tags = tags;
|
||||
|
|
@ -23321,6 +23270,41 @@ var lsp = (function (exports) {
|
|||
dispatch(setSel(state, selection));
|
||||
return true;
|
||||
};
|
||||
function addCursorVertically(view, forward) {
|
||||
let { state } = view, sel = state.selection, ranges = state.selection.ranges.slice();
|
||||
for (let range of state.selection.ranges) {
|
||||
let line = state.doc.lineAt(range.head);
|
||||
if (forward ? line.to < view.state.doc.length : line.from > 0)
|
||||
for (let cur = range;;) {
|
||||
let next = view.moveVertically(cur, forward);
|
||||
if (next.head < line.from || next.head > line.to) {
|
||||
if (!ranges.some(r => r.head == next.head))
|
||||
ranges.push(next);
|
||||
break;
|
||||
}
|
||||
else if (next.head == cur.head) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
cur = next;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ranges.length == sel.ranges.length)
|
||||
return false;
|
||||
view.dispatch(setSel(state, EditorSelection.create(ranges, ranges.length - 1)));
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
Expand the selection by adding a cursor above the heads of
|
||||
currently selected ranges.
|
||||
*/
|
||||
const addCursorAbove = view => addCursorVertically(view, false);
|
||||
/**
|
||||
Expand the selection by adding a cursor below the heads of
|
||||
currently selected ranges.
|
||||
*/
|
||||
const addCursorBelow = view => addCursorVertically(view, true);
|
||||
/**
|
||||
Simplify the current selection. When multiple ranges are selected,
|
||||
reduce it to its main range. Otherwise, if the selection is
|
||||
|
|
@ -23830,12 +23814,12 @@ var lsp = (function (exports) {
|
|||
{ key: "Mod-End", run: cursorDocEnd, shift: selectDocEnd },
|
||||
{ key: "Enter", run: insertNewlineAndIndent, shift: insertNewlineAndIndent },
|
||||
{ key: "Mod-a", run: selectAll },
|
||||
{ key: "Backspace", run: deleteCharBackward, shift: deleteCharBackward },
|
||||
{ key: "Delete", run: deleteCharForward },
|
||||
{ key: "Mod-Backspace", mac: "Alt-Backspace", run: deleteGroupBackward },
|
||||
{ key: "Mod-Delete", mac: "Alt-Delete", run: deleteGroupForward },
|
||||
{ mac: "Mod-Backspace", run: deleteLineBoundaryBackward },
|
||||
{ mac: "Mod-Delete", run: deleteLineBoundaryForward }
|
||||
{ key: "Backspace", run: deleteCharBackward, shift: deleteCharBackward, preventDefault: true },
|
||||
{ key: "Delete", run: deleteCharForward, preventDefault: true },
|
||||
{ key: "Mod-Backspace", mac: "Alt-Backspace", run: deleteGroupBackward, preventDefault: true },
|
||||
{ key: "Mod-Delete", mac: "Alt-Delete", run: deleteGroupForward, preventDefault: true },
|
||||
{ mac: "Mod-Backspace", run: deleteLineBoundaryBackward, preventDefault: true },
|
||||
{ mac: "Mod-Delete", run: deleteLineBoundaryForward, preventDefault: true }
|
||||
].concat(/*@__PURE__*/emacsStyleKeymap.map(b => ({ mac: b.key, run: b.run, shift: b.shift })));
|
||||
/**
|
||||
The default keymap. Includes all bindings from
|
||||
|
|
@ -23847,6 +23831,8 @@ var lsp = (function (exports) {
|
|||
- Alt-ArrowDown: [`moveLineDown`](https://codemirror.net/6/docs/ref/#commands.moveLineDown)
|
||||
- Shift-Alt-ArrowUp: [`copyLineUp`](https://codemirror.net/6/docs/ref/#commands.copyLineUp)
|
||||
- Shift-Alt-ArrowDown: [`copyLineDown`](https://codemirror.net/6/docs/ref/#commands.copyLineDown)
|
||||
- Ctrl-Alt-ArrowUp (Cmd-Alt-ArrowUp on macOS): [`addCursorAbove`](https://codemirror.net/6/docs/ref/#commands.addCursorAbove).
|
||||
- Ctrl-Alt-ArrowDown (Cmd-Alt-ArrowDown on macOS): [`addCursorBelow`](https://codemirror.net/6/docs/ref/#commands.addCursorBelow).
|
||||
- Escape: [`simplifySelection`](https://codemirror.net/6/docs/ref/#commands.simplifySelection)
|
||||
- Ctrl-Enter (Cmd-Enter on macOS): [`insertBlankLine`](https://codemirror.net/6/docs/ref/#commands.insertBlankLine)
|
||||
- Alt-l (Ctrl-l on macOS): [`selectLine`](https://codemirror.net/6/docs/ref/#commands.selectLine)
|
||||
|
|
@ -23867,6 +23853,8 @@ var lsp = (function (exports) {
|
|||
{ key: "Shift-Alt-ArrowUp", run: copyLineUp },
|
||||
{ key: "Alt-ArrowDown", run: moveLineDown },
|
||||
{ key: "Shift-Alt-ArrowDown", run: copyLineDown },
|
||||
{ key: "Mod-Alt-ArrowUp", run: addCursorAbove },
|
||||
{ key: "Mod-Alt-ArrowDown", run: addCursorBelow },
|
||||
{ key: "Escape", run: simplifySelection },
|
||||
{ key: "Mod-Enter", run: insertBlankLine },
|
||||
{ key: "Alt-l", mac: "Ctrl-l", run: selectLine },
|
||||
|
|
@ -24608,7 +24596,7 @@ var lsp = (function (exports) {
|
|||
}
|
||||
function sortOptions(active, state) {
|
||||
let options = [];
|
||||
let sections = null;
|
||||
let sections = null, dynamicSectionScore = null;
|
||||
let addOption = (option) => {
|
||||
options.push(option);
|
||||
let { section } = option.completion;
|
||||
|
|
@ -24635,13 +24623,24 @@ var lsp = (function (exports) {
|
|||
for (let option of a.result.options)
|
||||
if (match = matcher.match(option.label)) {
|
||||
let matched = !option.displayLabel ? match.matched : getMatch ? getMatch(option, match.matched) : [];
|
||||
addOption(new Option(option, a.source, matched, match.score + (option.boost || 0)));
|
||||
let score = match.score + (option.boost || 0);
|
||||
addOption(new Option(option, a.source, matched, score));
|
||||
if (typeof option.section == "object" && option.section.rank === "dynamic") {
|
||||
let { name } = option.section;
|
||||
if (!dynamicSectionScore)
|
||||
dynamicSectionScore = Object.create(null);
|
||||
dynamicSectionScore[name] = Math.max(score, dynamicSectionScore[name] || -1e9);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sections) {
|
||||
let sectionOrder = Object.create(null), pos = 0;
|
||||
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); };
|
||||
let cmp = (a, b) => {
|
||||
return (a.rank === "dynamic" && b.rank === "dynamic" ? dynamicSectionScore[b.name] - dynamicSectionScore[a.name] : 0) ||
|
||||
(typeof a.rank == "number" ? a.rank : 1e9) - (typeof b.rank == "number" ? b.rank : 1e9) ||
|
||||
(a.name < b.name ? -1 : 1);
|
||||
};
|
||||
for (let s of sections.sort(cmp)) {
|
||||
pos -= 1e5;
|
||||
sectionOrder[s.name] = pos;
|
||||
|
|
@ -31308,12 +31307,14 @@ ${text}</tr>
|
|||
const compartment = new Compartment();
|
||||
let curOpts = {
|
||||
lineWrap: true,
|
||||
minimap: true
|
||||
minimap: true,
|
||||
highlightWhitespace: true
|
||||
};
|
||||
// array of extensions reflecting opts
|
||||
function optExts(opts) {
|
||||
let exts = [];
|
||||
if (opts.lineWrap) exts.push(EditorView.lineWrapping);
|
||||
if (opts.highlightWhitespace) exts.push(highlightWhitespace());
|
||||
if (opts.minimap) exts.push(
|
||||
showMinimap.compute(['doc'], (state) => {
|
||||
return {
|
||||
|
|
@ -31352,7 +31353,6 @@ ${text}</tr>
|
|||
const baseExts = [
|
||||
lineNumbers(),
|
||||
highlightActiveLineGutter(),
|
||||
highlightSpecialChars(),
|
||||
history(),
|
||||
foldGutter(),
|
||||
lintGutter(),
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -139,8 +139,9 @@ function updateSettings(event) {
|
|||
|
||||
console.log("COPTS", lsp.curOpts);
|
||||
const opts = {
|
||||
lineWrap: $("lineWrap").checked,
|
||||
minimap: $("minimap").checked
|
||||
lineWrap: $("lineWrap").checked,
|
||||
highlightWhitespace: $("highlightWhitespace").checked,
|
||||
minimap: $("minimap").checked
|
||||
}
|
||||
console.log(opts)
|
||||
lsp.updateCompartment(opts);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue