@monaco-neovim-wasm/lib 0.1.22 → 0.1.24
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.
|
@@ -60,6 +60,7 @@ export declare class MonacoNeovimClient {
|
|
|
60
60
|
private ignoreSelectionSyncUntil;
|
|
61
61
|
private acceptNvimBufLinesDuringDelegatedInsertUntil;
|
|
62
62
|
private pendingModePull;
|
|
63
|
+
private suppressCursorRevealUntilMs;
|
|
63
64
|
private debugLog;
|
|
64
65
|
private nowMs;
|
|
65
66
|
private sendImeText;
|
|
@@ -394,7 +394,7 @@ function x(n) {
|
|
|
394
394
|
function T(n) {
|
|
395
395
|
return (typeof n == "string" ? n : "").startsWith("i");
|
|
396
396
|
}
|
|
397
|
-
function
|
|
397
|
+
function D(n) {
|
|
398
398
|
const e = typeof n == "string" ? n : "";
|
|
399
399
|
return e === "c" || e.startsWith("c");
|
|
400
400
|
}
|
|
@@ -415,8 +415,8 @@ function oe(n) {
|
|
|
415
415
|
if (typeof n.editor.hasTextFocus == "function" ? !!n.editor.hasTextFocus() : !1) return !0;
|
|
416
416
|
const m = l.target;
|
|
417
417
|
if (m && e.contains(m)) return !0;
|
|
418
|
-
const
|
|
419
|
-
return !!(
|
|
418
|
+
const S = t.activeElement;
|
|
419
|
+
return !!(S && e.contains(S));
|
|
420
420
|
} catch {
|
|
421
421
|
return !1;
|
|
422
422
|
}
|
|
@@ -445,48 +445,48 @@ function oe(n) {
|
|
|
445
445
|
n.exitDelegatedInsertMode("<Esc>");
|
|
446
446
|
return;
|
|
447
447
|
}
|
|
448
|
-
const
|
|
449
|
-
(
|
|
448
|
+
const v = l.key;
|
|
449
|
+
(v === "ArrowLeft" || v === "ArrowRight" || v === "ArrowUp" || v === "ArrowDown" || v === "Home" || v === "End" || v === "PageUp" || v === "PageDown" || v === "Tab" || v === "Enter") && n.setDelegatedInsertReplayPossible(!1);
|
|
450
450
|
}
|
|
451
451
|
if (!g && (l.key === "Backspace" || l.key === "Delete" || l.key === "Escape")) {
|
|
452
452
|
if (!n.shouldHandleKey(l)) return;
|
|
453
|
-
const
|
|
454
|
-
if (!
|
|
453
|
+
const v = n.translateKey(l);
|
|
454
|
+
if (!v) return;
|
|
455
455
|
s(l);
|
|
456
456
|
try {
|
|
457
457
|
l.preventDefault();
|
|
458
458
|
} catch {
|
|
459
459
|
}
|
|
460
|
-
if (n.isExitingInsertMode() &&
|
|
461
|
-
n.isExitingInsertMode() ? n.appendPendingKeysAfterExit(
|
|
460
|
+
if (n.isExitingInsertMode() && v === "<Esc>") return;
|
|
461
|
+
n.isExitingInsertMode() ? n.appendPendingKeysAfterExit(v) : (n.sendInput(v), n.scheduleCursorRefresh(), x(m) && n.scheduleVisualSelectionRefresh());
|
|
462
462
|
return;
|
|
463
463
|
}
|
|
464
464
|
if (!g && !n.isExitingInsertMode() && (l.key === "ArrowLeft" || l.key === "ArrowRight" || l.key === "ArrowUp" || l.key === "ArrowDown" || l.key === "Home" || l.key === "End" || l.key === "PageUp" || l.key === "PageDown")) {
|
|
465
465
|
if (!n.shouldHandleKey(l)) return;
|
|
466
|
-
const
|
|
467
|
-
if (!
|
|
466
|
+
const v = n.translateKey(l);
|
|
467
|
+
if (!v) return;
|
|
468
468
|
s(l);
|
|
469
469
|
try {
|
|
470
470
|
l.preventDefault();
|
|
471
471
|
} catch {
|
|
472
472
|
}
|
|
473
|
-
n.isExitingInsertMode() ? n.appendPendingKeysAfterExit(
|
|
473
|
+
n.isExitingInsertMode() ? n.appendPendingKeysAfterExit(v) : (n.sendInput(v), n.scheduleCursorRefresh(), x(m) && n.scheduleVisualSelectionRefresh());
|
|
474
474
|
return;
|
|
475
475
|
}
|
|
476
|
-
if (
|
|
477
|
-
const
|
|
478
|
-
if (!!!(l.altKey &&
|
|
476
|
+
if (D(m) && !n.isDelegateInsertToMonaco() && !n.isExitingInsertMode() && !l.ctrlKey && !l.metaKey && typeof l.key == "string" && l.key.length === 1) {
|
|
477
|
+
const v = /^[\x20-\x7E]$/.test(l.key);
|
|
478
|
+
if (!!!(l.altKey && v)) {
|
|
479
479
|
if (!n.shouldHandleKey(l)) return;
|
|
480
480
|
s(l);
|
|
481
481
|
return;
|
|
482
482
|
}
|
|
483
483
|
}
|
|
484
484
|
if (!l.ctrlKey && !l.altKey && !l.metaKey) return;
|
|
485
|
-
const
|
|
486
|
-
if (!
|
|
485
|
+
const S = n.modifiedKeyName(l);
|
|
486
|
+
if (!S || !n.shouldHandleKey(l)) return;
|
|
487
487
|
if (n.hasExplicitModAllowlist(g)) {
|
|
488
488
|
if (!n.shouldForwardModifiedKeys(l, g)) return;
|
|
489
|
-
} else if (g || !l.ctrlKey || l.altKey || l.metaKey ||
|
|
489
|
+
} else if (g || !l.ctrlKey || l.altKey || l.metaKey || S !== "f" && S !== "b" && S !== "d" && S !== "u" && S !== "e" && S !== "y" && S !== "v") return;
|
|
490
490
|
const C = n.translateKey(l);
|
|
491
491
|
if (C) {
|
|
492
492
|
s(l);
|
|
@@ -525,13 +525,13 @@ function oe(n) {
|
|
|
525
525
|
return;
|
|
526
526
|
}
|
|
527
527
|
const m = o(l.target);
|
|
528
|
-
if (T(g) && !
|
|
529
|
-
const
|
|
530
|
-
|
|
528
|
+
if (T(g) && !D(g)) {
|
|
529
|
+
const S = typeof l.data == "string" ? l.data : "", C = !S && m && m.tagName === "TEXTAREA" && m.value ? String(m.value) : !S && m?.textContent ? String(m.textContent) : "", v = S || C;
|
|
530
|
+
v && n.sendImeText(v);
|
|
531
531
|
}
|
|
532
|
-
if (
|
|
533
|
-
const
|
|
534
|
-
|
|
532
|
+
if (D(g)) {
|
|
533
|
+
const S = typeof l.data == "string" ? l.data : "", C = !S && m && m.tagName === "TEXTAREA" && m.value ? String(m.value) : !S && m?.textContent ? String(m.textContent) : "", v = S || C;
|
|
534
|
+
v && n.sendImeText(v);
|
|
535
535
|
}
|
|
536
536
|
try {
|
|
537
537
|
m && m.tagName === "TEXTAREA" ? m.value = "" : m && (m.textContent = "");
|
|
@@ -567,10 +567,10 @@ function oe(n) {
|
|
|
567
567
|
l.preventDefault?.();
|
|
568
568
|
} catch {
|
|
569
569
|
}
|
|
570
|
-
const
|
|
571
|
-
if (T(
|
|
572
|
-
const C = typeof g.inputType == "string" ? String(g.inputType) : "",
|
|
573
|
-
if (!
|
|
570
|
+
const S = n.getLastMode();
|
|
571
|
+
if (T(S) && !n.isCompositionActive()) {
|
|
572
|
+
const C = typeof g.inputType == "string" ? String(g.inputType) : "", v = !!g.isComposing, I = typeof g.data == "string" ? g.data : "";
|
|
573
|
+
if (!v && !C.includes("Composition")) {
|
|
574
574
|
if (C === "insertText" || C === "insertReplacementText" || C === "insertFromDrop") {
|
|
575
575
|
I && (n.armIgnoreNextInputEvent(g.target, 120, I), n.sendImeText(I));
|
|
576
576
|
try {
|
|
@@ -605,9 +605,9 @@ function oe(n) {
|
|
|
605
605
|
}
|
|
606
606
|
}
|
|
607
607
|
}
|
|
608
|
-
if (
|
|
609
|
-
const C = l,
|
|
610
|
-
!C.isComposing && !I.includes("Composition") &&
|
|
608
|
+
if (D(S) && !n.isCompositionActive()) {
|
|
609
|
+
const C = l, v = typeof C.data == "string" ? C.data : "", I = typeof C.inputType == "string" ? String(C.inputType) : "";
|
|
610
|
+
!C.isComposing && !I.includes("Composition") && v && n.sendImeText(v);
|
|
611
611
|
}
|
|
612
612
|
}, f = (l) => {
|
|
613
613
|
if (!r(l)) return;
|
|
@@ -638,13 +638,13 @@ function oe(n) {
|
|
|
638
638
|
return;
|
|
639
639
|
}
|
|
640
640
|
if (n.isCompositionActive()) return;
|
|
641
|
-
const
|
|
642
|
-
if (T(
|
|
643
|
-
const C = typeof g.data == "string" ? g.data : "",
|
|
641
|
+
const S = n.getLastMode();
|
|
642
|
+
if (T(S) && !D(S)) {
|
|
643
|
+
const C = typeof g.data == "string" ? g.data : "", v = !C && m?.tagName === "TEXTAREA" && m.value ? String(m.value) : !C && m?.textContent ? String(m.textContent) : "", I = C || v;
|
|
644
644
|
I && (n.armIgnoreNextInputEvent(g.target, 120, I), n.sendImeText(I));
|
|
645
645
|
}
|
|
646
|
-
if (
|
|
647
|
-
const C = typeof g.data == "string" ? g.data : "",
|
|
646
|
+
if (D(S)) {
|
|
647
|
+
const C = typeof g.data == "string" ? g.data : "", v = !C && m?.tagName === "TEXTAREA" && m.value ? String(m.value) : !C && m?.textContent ? String(m.textContent) : "", I = C || v;
|
|
648
648
|
I && n.sendImeText(I);
|
|
649
649
|
}
|
|
650
650
|
try {
|
|
@@ -662,16 +662,16 @@ function oe(n) {
|
|
|
662
662
|
} catch {
|
|
663
663
|
}
|
|
664
664
|
};
|
|
665
|
-
let y = !1,
|
|
666
|
-
const N = (l) => `${l.shiftKey ? "S" : ""}${l.ctrlKey ? "C" : ""}${l.altKey ? "A" : ""}${l.metaKey ? "D" : ""}`,
|
|
665
|
+
let y = !1, _ = "left", R = null, w = "", M = null;
|
|
666
|
+
const N = (l) => `${l.shiftKey ? "S" : ""}${l.ctrlKey ? "C" : ""}${l.altKey ? "A" : ""}${l.metaKey ? "D" : ""}`, A = (l) => l.button === 1 ? "middle" : l.button === 2 ? "right" : "left", L = (l) => {
|
|
667
667
|
try {
|
|
668
|
-
const
|
|
669
|
-
return
|
|
668
|
+
const S = n.editor.getTargetAtClientPoint?.(l.clientX, l.clientY)?.position;
|
|
669
|
+
return S ? new b.Position(S.lineNumber, S.column) : null;
|
|
670
670
|
} catch {
|
|
671
671
|
return null;
|
|
672
672
|
}
|
|
673
673
|
}, B = () => {
|
|
674
|
-
M = null, y && R && (n.setIgnoreSelectionSyncUntil(n.nowMs() + 200), n.sendNvimMouse(
|
|
674
|
+
M = null, y && R && (n.setIgnoreSelectionSyncUntil(n.nowMs() + 200), n.sendNvimMouse(_, "drag", w, R));
|
|
675
675
|
}, V = (l) => {
|
|
676
676
|
if (!r(l) || n.isDelegateInsertToMonaco() && !n.isExitingInsertMode() || n.isCompositionActive() || l.isComposing || l.button !== 0 && l.button !== 1 && l.button !== 2) return;
|
|
677
677
|
const g = L(l);
|
|
@@ -685,7 +685,7 @@ function oe(n) {
|
|
|
685
685
|
n.editor.focus();
|
|
686
686
|
} catch {
|
|
687
687
|
}
|
|
688
|
-
y = !0,
|
|
688
|
+
y = !0, _ = A(l), w = N(l), R = g, M && (clearTimeout(M), M = null), n.setIgnoreSelectionSyncUntil(n.nowMs() + 250), n.sendNvimMouse(_, "press", w, g);
|
|
689
689
|
}
|
|
690
690
|
}, W = (l) => {
|
|
691
691
|
if (!y || !r(l) || n.isDelegateInsertToMonaco() && !n.isExitingInsertMode() || n.isCompositionActive() || l.isComposing) return;
|
|
@@ -712,7 +712,7 @@ function oe(n) {
|
|
|
712
712
|
} catch {
|
|
713
713
|
}
|
|
714
714
|
}
|
|
715
|
-
M && (clearTimeout(M), M = null), w = N(l), R = m, n.setIgnoreSelectionSyncUntil(n.nowMs() + 250), n.sendNvimMouse(
|
|
715
|
+
M && (clearTimeout(M), M = null), w = N(l), R = m, n.setIgnoreSelectionSyncUntil(n.nowMs() + 250), n.sendNvimMouse(_, "release", w, m);
|
|
716
716
|
}
|
|
717
717
|
}, ie = (l) => {
|
|
718
718
|
if (r(l) && !(n.isDelegateInsertToMonaco() && !n.isExitingInsertMode())) {
|
|
@@ -743,8 +743,8 @@ function ae(n, e, t, i, s, r) {
|
|
|
743
743
|
if (p.length <= 1)
|
|
744
744
|
f = [`${c}${p[0] ?? ""}${u}`];
|
|
745
745
|
else {
|
|
746
|
-
const h = `${c}${p[0] ?? ""}`, y = `${p[p.length - 1] ?? ""}${u}`,
|
|
747
|
-
f = [h, ...
|
|
746
|
+
const h = `${c}${p[0] ?? ""}`, y = `${p[p.length - 1] ?? ""}${u}`, _ = p.slice(1, -1);
|
|
747
|
+
f = [h, ..._, y];
|
|
748
748
|
}
|
|
749
749
|
n.splice(e, Math.max(0, i - e + 1), ...f);
|
|
750
750
|
}
|
|
@@ -831,8 +831,8 @@ class le {
|
|
|
831
831
|
if (!this.init.getBufHandle()) return { kind: "noop" };
|
|
832
832
|
if (this.init.isCompositionActive() || e?.isComposing) return { kind: "noop" };
|
|
833
833
|
if (!e?.changes?.length) return { kind: "noop" };
|
|
834
|
-
const
|
|
835
|
-
return
|
|
834
|
+
const A = this.init.getSyncModelFromMonaco();
|
|
835
|
+
return A === "always" ? (this.scheduleSyncBufferToNvim(), { kind: "syncToNvimScheduled" }) : A !== "never" ? (this.scheduleResync(), { kind: "resyncScheduled" }) : { kind: "noop" };
|
|
836
836
|
}
|
|
837
837
|
if (this.init.isApplyingFromNvim()) return { kind: "noop" };
|
|
838
838
|
if (!this.init.isSessionRunning()) return { kind: "noop" };
|
|
@@ -870,11 +870,11 @@ class le {
|
|
|
870
870
|
}
|
|
871
871
|
return this.scheduleFlushPendingMonacoSync(), { kind: "delegatedInsertPatched", resetDotRepeat: !0, resetReplayPossible: !0 };
|
|
872
872
|
}
|
|
873
|
-
const u = s.shadowLines[a] ?? "", d = s.shadowLines[c] ?? "", p = Math.max(0, o.startColumn - 1), f = Math.max(0, o.endColumn - 1), h = P(u, p), y = P(d, f),
|
|
874
|
-
s.pendingBufEdits.push({ startRow: a, startColByte: h, endRow: c, endColByte: y, lines: R }), ae(s.shadowLines, a, p, c, f,
|
|
875
|
-
const w = Math.max(0, Number(r.rangeLength ?? 0) || 0), M = a === c && !
|
|
873
|
+
const u = s.shadowLines[a] ?? "", d = s.shadowLines[c] ?? "", p = Math.max(0, o.startColumn - 1), f = Math.max(0, o.endColumn - 1), h = P(u, p), y = P(d, f), _ = String(r.text ?? ""), R = _.length ? _.split(/\r?\n/) : [];
|
|
874
|
+
s.pendingBufEdits.push({ startRow: a, startColByte: h, endRow: c, endColByte: y, lines: R }), ae(s.shadowLines, a, p, c, f, _), s.pendingCursorSync = !0, this.scheduleFlushPendingMonacoSync();
|
|
875
|
+
const w = Math.max(0, Number(r.rangeLength ?? 0) || 0), M = a === c && !_.includes(`
|
|
876
876
|
`);
|
|
877
|
-
return { kind: "delegatedInsertPatched", dotRepeat: { deleted: w, text:
|
|
877
|
+
return { kind: "delegatedInsertPatched", dotRepeat: { deleted: w, text: _, simple: M }, resetDotRepeat: !M };
|
|
878
878
|
}
|
|
879
879
|
scheduleCursorSyncToNvim() {
|
|
880
880
|
if (!this.init.isDelegateInsertToMonaco() || this.init.isExitingInsertMode()) return;
|
|
@@ -951,12 +951,12 @@ class le {
|
|
|
951
951
|
this.init.setPendingResyncAfterComposition(!0);
|
|
952
952
|
return;
|
|
953
953
|
}
|
|
954
|
-
const f = p.model, h = Number(a), y = Number(c),
|
|
955
|
-
if (f && Number.isInteger(h) && Number.isInteger(y) && h >= 0 && y >= h &&
|
|
954
|
+
const f = p.model, h = Number(a), y = Number(c), _ = Array.isArray(u) ? u.map((w) => String(w ?? "")) : null;
|
|
955
|
+
if (f && Number.isInteger(h) && Number.isInteger(y) && h >= 0 && y >= h && _)
|
|
956
956
|
try {
|
|
957
957
|
const w = d != null && i === d && this.init.editor.getModel() === f;
|
|
958
958
|
if (w && this.init.isDelegateInsertToMonaco()) {
|
|
959
|
-
const M = this.computeLinePatch(f, h, y,
|
|
959
|
+
const M = this.computeLinePatch(f, h, y, _);
|
|
960
960
|
let N = !1;
|
|
961
961
|
try {
|
|
962
962
|
N = f.getValueInRange(M.range) === M.text;
|
|
@@ -971,13 +971,13 @@ class le {
|
|
|
971
971
|
this.scheduleResync();
|
|
972
972
|
return;
|
|
973
973
|
}
|
|
974
|
-
this.applyLinePatchToModel(f, h, y,
|
|
974
|
+
this.applyLinePatchToModel(f, h, y, _);
|
|
975
975
|
try {
|
|
976
976
|
p.shadowLines = f.getLinesContent();
|
|
977
977
|
} catch {
|
|
978
978
|
}
|
|
979
979
|
}
|
|
980
|
-
} else w ? (this.applyLinePatch(f, h, y,
|
|
980
|
+
} else w ? (this.applyLinePatch(f, h, y, _), this.init.isDelegateInsertToMonaco() || this.init.scheduleCursorRefresh()) : w ? this.applyLinePatch(f, h, y, _) : this.applyLinePatchToModel(f, h, y, _);
|
|
981
981
|
} catch {
|
|
982
982
|
}
|
|
983
983
|
else
|
|
@@ -1488,15 +1488,15 @@ class de {
|
|
|
1488
1488
|
return d.set(f, h), h;
|
|
1489
1489
|
};
|
|
1490
1490
|
for (let f = 0; f < r.length && c.length < u; f += 1) {
|
|
1491
|
-
const h = r[f], y = Number(h?.l),
|
|
1492
|
-
if (!Number.isFinite(y) || !Number.isFinite(
|
|
1491
|
+
const h = r[f], y = Number(h?.l), _ = Number(h?.s), R = Number(h?.e);
|
|
1492
|
+
if (!Number.isFinite(y) || !Number.isFinite(_) || !Number.isFinite(R)) continue;
|
|
1493
1493
|
const w = y + 1;
|
|
1494
1494
|
if (w < 1 || w > t.getLineCount()) continue;
|
|
1495
|
-
const M = p(w), N = $(M, Math.max(0,
|
|
1496
|
-
if (
|
|
1497
|
-
const L = `${y}:${
|
|
1495
|
+
const M = p(w), N = $(M, Math.max(0, _)) + 1, A = $(M, Math.max(0, R)) + 1;
|
|
1496
|
+
if (A <= N) continue;
|
|
1497
|
+
const L = `${y}:${_}:${R}`, B = !!(a && L === a), V = B ? "currentFindMatch" : "findMatch", W = B ? "currentFindMatchInline" : "findMatchInline";
|
|
1498
1498
|
c.push({
|
|
1499
|
-
range: new b.Range(w, N, w,
|
|
1499
|
+
range: new b.Range(w, N, w, A),
|
|
1500
1500
|
options: { className: V, inlineClassName: W }
|
|
1501
1501
|
});
|
|
1502
1502
|
}
|
|
@@ -2091,7 +2091,7 @@ function Z(n, e, t) {
|
|
|
2091
2091
|
const o = r.getLineCount(), a = G(i, 1, o), c = r.getLineContent(a) ?? "", u = r.getLineMaxColumn(a), d = Math.max(0, Number(t) || 0), p = $(c, d), f = G(p + 1, 1, u);
|
|
2092
2092
|
return { line: a, col: f };
|
|
2093
2093
|
}
|
|
2094
|
-
class
|
|
2094
|
+
class ve {
|
|
2095
2095
|
init;
|
|
2096
2096
|
constructor(e) {
|
|
2097
2097
|
this.init = e;
|
|
@@ -2106,37 +2106,37 @@ class _e {
|
|
|
2106
2106
|
if (t <= 0) return !1;
|
|
2107
2107
|
const i = e ?? this.init.editor.getPosition();
|
|
2108
2108
|
if (!i) return !1;
|
|
2109
|
-
|
|
2110
|
-
if (r <= 0) return !1;
|
|
2111
|
-
let o = 0;
|
|
2109
|
+
let s = 0;
|
|
2112
2110
|
try {
|
|
2113
2111
|
const y = this.init.editor.getLayoutInfo();
|
|
2114
|
-
|
|
2112
|
+
s = Math.max(0, Number(y?.contentHeight ?? y?.height ?? 0) || 0);
|
|
2115
2113
|
} catch {
|
|
2116
2114
|
}
|
|
2117
|
-
if (
|
|
2118
|
-
const
|
|
2115
|
+
if (s <= 0) return !1;
|
|
2116
|
+
const r = () => {
|
|
2119
2117
|
try {
|
|
2120
2118
|
this.init.editor.revealPositionInCenterIfOutsideViewport(i);
|
|
2121
2119
|
} catch {
|
|
2122
2120
|
}
|
|
2123
2121
|
};
|
|
2124
|
-
let
|
|
2122
|
+
let o = null;
|
|
2125
2123
|
try {
|
|
2126
|
-
|
|
2124
|
+
o = this.init.editor.getScrolledVisiblePosition(i);
|
|
2127
2125
|
} catch {
|
|
2128
2126
|
}
|
|
2129
|
-
if (!
|
|
2130
|
-
|
|
2127
|
+
if (!o) {
|
|
2128
|
+
r();
|
|
2131
2129
|
try {
|
|
2132
|
-
|
|
2130
|
+
o = this.init.editor.getScrolledVisiblePosition(i);
|
|
2133
2131
|
} catch {
|
|
2134
2132
|
}
|
|
2135
2133
|
}
|
|
2136
|
-
if (!
|
|
2137
|
-
const
|
|
2134
|
+
if (!o || !Number.isFinite(o.top) || !Number.isFinite(o.height)) return !1;
|
|
2135
|
+
const a = Math.max(1, Number(o.height) || 0), c = t * a;
|
|
2136
|
+
if (c <= 0) return !1;
|
|
2137
|
+
const u = this.init.editor.getScrollTop(), d = o.top, p = o.top + o.height, f = Math.max(0, s - c);
|
|
2138
2138
|
let h = 0;
|
|
2139
|
-
if (d <
|
|
2139
|
+
if (d < c ? h = d - c : p > f && (h = p - f), !h) return !1;
|
|
2140
2140
|
try {
|
|
2141
2141
|
this.init.editor.setScrollTop(Math.max(0, u + h));
|
|
2142
2142
|
} catch {
|
|
@@ -2177,7 +2177,7 @@ class _e {
|
|
|
2177
2177
|
if (!h) return !1;
|
|
2178
2178
|
this.init.setSuppressCursorSync(!0);
|
|
2179
2179
|
try {
|
|
2180
|
-
const
|
|
2180
|
+
const _ = this.init.editor.getScrollTop(), R = Math.max(0, _ + h * f * u);
|
|
2181
2181
|
this.init.editor.setScrollTop(R);
|
|
2182
2182
|
} catch {
|
|
2183
2183
|
}
|
|
@@ -2194,27 +2194,28 @@ class _e {
|
|
|
2194
2194
|
return this.init.setSuppressCursorSync(!1), y;
|
|
2195
2195
|
}
|
|
2196
2196
|
applyMonacoReveal(e) {
|
|
2197
|
-
const t = typeof e.direction == "string" ? e.direction : "", i = !!e.resetCursor, s = this.init.editor.getPosition();
|
|
2198
|
-
if (!
|
|
2199
|
-
const
|
|
2197
|
+
const t = typeof e.direction == "string" ? e.direction : "", i = !!e.resetCursor, s = this.init.editor.getPosition(), r = Number(e.line), o = Number.isFinite(r) && r > 0 ? Math.floor(r) : s?.lineNumber ?? 0;
|
|
2198
|
+
if (!o) return !1;
|
|
2199
|
+
const a = Math.max(1, Math.floor(Number(s?.column ?? 1) || 1)), c = Math.max(1, this.init.getUiRows() || this.init.getDefaultRows()), u = this.init.editor.getOption(b.editor.EditorOption.fontInfo), d = Math.max(1, Number(u?.lineHeight ?? 0) || 0);
|
|
2200
2200
|
this.init.setSuppressCursorSync(!0);
|
|
2201
2201
|
try {
|
|
2202
2202
|
if (t === "top") {
|
|
2203
|
-
const
|
|
2204
|
-
this.init.editor.setScrollTop(
|
|
2203
|
+
const p = this.init.editor.getTopForLineNumber(o);
|
|
2204
|
+
this.init.editor.setScrollTop(p);
|
|
2205
2205
|
} else if (t === "center")
|
|
2206
|
-
this.init.editor.revealLineInCenter(
|
|
2206
|
+
this.init.editor.revealLineInCenter(o);
|
|
2207
2207
|
else if (t === "bottom") {
|
|
2208
|
-
const
|
|
2209
|
-
this.init.editor.setScrollTop(
|
|
2208
|
+
const p = this.init.editor.getTopForLineNumber(o), f = Math.max(0, p - (c - 1) * d);
|
|
2209
|
+
this.init.editor.setScrollTop(f);
|
|
2210
2210
|
}
|
|
2211
2211
|
if (i) {
|
|
2212
|
-
const
|
|
2213
|
-
if (
|
|
2214
|
-
const
|
|
2215
|
-
this.init.editor.setPosition(
|
|
2212
|
+
const p = this.init.editor.getModel();
|
|
2213
|
+
if (p) {
|
|
2214
|
+
const f = p.getLineContent(o) ?? "", h = /\S/.exec(f), y = h ? h.index + 1 : 1, _ = p.validatePosition(new b.Position(o, y));
|
|
2215
|
+
this.init.editor.setPosition(_), this.init.setLastCursorPos(_);
|
|
2216
2216
|
}
|
|
2217
2217
|
}
|
|
2218
|
+
this.applyScrolloff(new b.Position(o, a));
|
|
2218
2219
|
} catch {
|
|
2219
2220
|
}
|
|
2220
2221
|
return this.init.setSuppressCursorSync(!1), i;
|
|
@@ -2251,7 +2252,7 @@ class _e {
|
|
|
2251
2252
|
this.init.setLastCursorPos(p), this.init.setSuppressCursorSync(!1);
|
|
2252
2253
|
}
|
|
2253
2254
|
}
|
|
2254
|
-
class
|
|
2255
|
+
class _e {
|
|
2255
2256
|
init;
|
|
2256
2257
|
delegateInsertToMonaco = !1;
|
|
2257
2258
|
exitingInsertMode = !1;
|
|
@@ -2503,7 +2504,7 @@ class Me {
|
|
|
2503
2504
|
return;
|
|
2504
2505
|
}
|
|
2505
2506
|
const s = this.init.getLastMode();
|
|
2506
|
-
if (
|
|
2507
|
+
if (D(s) && !this.init.isCompositionActive() && !t.isComposing && !t.getModifierState?.("AltGraph") && !t.ctrlKey && !t.metaKey && typeof t.key == "string" && t.key.length === 1) {
|
|
2507
2508
|
const u = /^[\x20-\x7E]$/.test(t.key);
|
|
2508
2509
|
if (!!!(t.altKey && u))
|
|
2509
2510
|
return this.init.shouldHandleKey(t), void 0;
|
|
@@ -2616,9 +2617,9 @@ class Ie {
|
|
|
2616
2617
|
if (!e.seedFromMonaco) return null;
|
|
2617
2618
|
const h = this.init.editor.getModel();
|
|
2618
2619
|
if (!h) return null;
|
|
2619
|
-
const y = h.getValue(),
|
|
2620
|
+
const y = h.getValue(), _ = String(y ?? "").replace(/\r\n?/g, `
|
|
2620
2621
|
`);
|
|
2621
|
-
return
|
|
2622
|
+
return _ ? _.split(`
|
|
2622
2623
|
`) : null;
|
|
2623
2624
|
}, r = this.init.getNextSeedLines(), o = (r && r.length ? r : null) ?? (e.seedLines && e.seedLines.length ? e.seedLines : null) ?? s();
|
|
2624
2625
|
this.init.clearNextSeedLines();
|
|
@@ -2734,7 +2735,8 @@ function! s:reveal(direction, resetCursor) abort
|
|
|
2734
2735
|
endif
|
|
2735
2736
|
return
|
|
2736
2737
|
endif
|
|
2737
|
-
|
|
2738
|
+
" Send the Neovim cursor line to avoid races where Monaco cursor sync is delayed.
|
|
2739
|
+
call rpcnotify(g:monaco_neovim_wasm_chan, 'monaco_reveal', { 'direction': a:direction, 'resetCursor': a:resetCursor, 'line': line('.') })
|
|
2738
2740
|
endfunction
|
|
2739
2741
|
|
|
2740
2742
|
nnoremap <silent> z<CR> <Cmd>call <SID>reveal('top', v:true)<CR>
|
|
@@ -3039,7 +3041,7 @@ local function get_selections(win)
|
|
|
3039
3041
|
end
|
|
3040
3042
|
|
|
3041
3043
|
return get_selections(...)
|
|
3042
|
-
`,
|
|
3044
|
+
`, Ae = `local api, fn = vim.api, vim.fn
|
|
3043
3045
|
|
|
3044
3046
|
local function get_visible_range(s, e)
|
|
3045
3047
|
s = tonumber(s) or 1
|
|
@@ -3128,7 +3130,7 @@ end
|
|
|
3128
3130
|
return run(...)
|
|
3129
3131
|
|
|
3130
3132
|
`;
|
|
3131
|
-
class
|
|
3133
|
+
class De {
|
|
3132
3134
|
init;
|
|
3133
3135
|
constructor(e) {
|
|
3134
3136
|
this.init = e;
|
|
@@ -4185,6 +4187,7 @@ class dt {
|
|
|
4185
4187
|
ignoreSelectionSyncUntil = 0;
|
|
4186
4188
|
acceptNvimBufLinesDuringDelegatedInsertUntil = 0;
|
|
4187
4189
|
pendingModePull = !1;
|
|
4190
|
+
suppressCursorRevealUntilMs = 0;
|
|
4188
4191
|
debugLog(e) {
|
|
4189
4192
|
if (this.opts.debug)
|
|
4190
4193
|
try {
|
|
@@ -4334,7 +4337,7 @@ class dt {
|
|
|
4334
4337
|
isSessionRunning: () => !!(this.session && this.session.isRunning()),
|
|
4335
4338
|
getBufHandle: () => this.bufHandle,
|
|
4336
4339
|
execLua: (i, s) => this.execLua(i, s),
|
|
4337
|
-
luaScript:
|
|
4340
|
+
luaScript: Ae,
|
|
4338
4341
|
isStagingFrame: () => this.redraw.isStagingFrame(),
|
|
4339
4342
|
markSearchRefresh: () => this.redraw.markSearchRefresh(),
|
|
4340
4343
|
debugLog: (i) => this.debugLog(i)
|
|
@@ -4365,7 +4368,7 @@ class dt {
|
|
|
4365
4368
|
this.lastMode = i;
|
|
4366
4369
|
},
|
|
4367
4370
|
onModeChange: this.opts.onModeChange
|
|
4368
|
-
}), this.insertDelegation = new
|
|
4371
|
+
}), this.insertDelegation = new _e({
|
|
4369
4372
|
editor: this.editor,
|
|
4370
4373
|
nowMs: () => this.nowMs(),
|
|
4371
4374
|
debugLog: (i) => this.debugLog(i),
|
|
@@ -4383,7 +4386,7 @@ class dt {
|
|
|
4383
4386
|
getBufHandle: () => this.bufHandle,
|
|
4384
4387
|
rpcCall: (i, s) => this.rpcCall(i, s),
|
|
4385
4388
|
sendInput: (i) => this.sendInput(i)
|
|
4386
|
-
}), this.viewport = new
|
|
4389
|
+
}), this.viewport = new ve({
|
|
4387
4390
|
editor: this.editor,
|
|
4388
4391
|
getUiRows: () => this.uiRows,
|
|
4389
4392
|
getDefaultRows: () => this.opts.rows,
|
|
@@ -4478,7 +4481,7 @@ class dt {
|
|
|
4478
4481
|
sendInput: (i) => this.sendInput(i),
|
|
4479
4482
|
scheduleCursorRefresh: () => this.scheduleCursorRefresh(),
|
|
4480
4483
|
scheduleVisualSelectionRefresh: () => this.visualSelection.scheduleRefresh()
|
|
4481
|
-
}), this.mouse = new
|
|
4484
|
+
}), this.mouse = new De({
|
|
4482
4485
|
editor: this.editor,
|
|
4483
4486
|
isSessionRunning: () => !!(this.session && this.session.isRunning()),
|
|
4484
4487
|
getBufHandle: () => this.bufHandle,
|
|
@@ -4695,7 +4698,7 @@ class dt {
|
|
|
4695
4698
|
}
|
|
4696
4699
|
handleNotifyMonacoReveal(e) {
|
|
4697
4700
|
const t = e?.[0];
|
|
4698
|
-
t && typeof t == "object" && this.viewport.applyMonacoReveal(t) && !this.insertDelegation.isExitingInsertMode() && this.syncCursorToNvimNow(!0);
|
|
4701
|
+
t && typeof t == "object" && (this.suppressCursorRevealUntilMs = this.nowMs() + 80, this.viewport.applyMonacoReveal(t) && !this.insertDelegation.isExitingInsertMode() && this.syncCursorToNvimNow(!0));
|
|
4699
4702
|
}
|
|
4700
4703
|
handleNotifyMonacoMoveCursor(e) {
|
|
4701
4704
|
const t = e?.[0];
|
|
@@ -4856,7 +4859,7 @@ class dt {
|
|
|
4856
4859
|
const i = typeof e == "string" ? e : "", s = t == null ? this.nvimBlocking : !!t, r = !!(i && i !== this.lastMode), o = s !== this.nvimBlocking;
|
|
4857
4860
|
if (!r && !o) return;
|
|
4858
4861
|
const a = this.lastMode;
|
|
4859
|
-
if (r && (this.lastMode = i,
|
|
4862
|
+
if (r && (this.lastMode = i, D(i) && this.inputEventDeduper.clear(), this.setMonacoHighlightsSuppressed(!1)), this.nvimBlocking = s, this.insertDelegation.applyMode(this.lastMode), r && (this.cursor.applyCursorStyle(i), this.opts.onModeChange && this.opts.onModeChange(i), this.visualSelection.updateVisualSelection(i), T(a) && !T(i) && this.scheduleCursorRefresh()), r && x(a) && !x(i))
|
|
4860
4863
|
try {
|
|
4861
4864
|
const c = this.editor.getPosition() ?? this.cursor.getLastCursorPos();
|
|
4862
4865
|
c && !this.compositionActive && (this.suppressCursorSync = !0, this.editor.setSelection(new b.Selection(c.lineNumber, c.column, c.lineNumber, c.column)), this.suppressCursorSync = !1);
|
|
@@ -4968,10 +4971,10 @@ class dt {
|
|
|
4968
4971
|
if (!(c && c.lineNumber === o.lineNumber && c.column === o.column)) {
|
|
4969
4972
|
const d = this.nowMs(), p = a || this.visualSelection.shouldKeepSelection(d, 120);
|
|
4970
4973
|
if (x(this.lastMode) || p) {
|
|
4971
|
-
this.viewport.applyScrolloff(o)
|
|
4974
|
+
!this.viewport.applyScrolloff(o) && d > this.suppressCursorRevealUntilMs && this.editor.revealPositionInCenterIfOutsideViewport(o), this.requestSearchHighlightRefresh();
|
|
4972
4975
|
return;
|
|
4973
4976
|
}
|
|
4974
|
-
this.suppressCursorSync = !0, this.editor.setPosition(o), this.viewport.applyScrolloff(o)
|
|
4977
|
+
this.suppressCursorSync = !0, this.editor.setPosition(o), !this.viewport.applyScrolloff(o) && d > this.suppressCursorRevealUntilMs && this.editor.revealPositionInCenterIfOutsideViewport(o), this.suppressCursorSync = !1;
|
|
4975
4978
|
}
|
|
4976
4979
|
this.requestSearchHighlightRefresh();
|
|
4977
4980
|
}
|
|
@@ -5007,7 +5010,9 @@ class dt {
|
|
|
5007
5010
|
} finally {
|
|
5008
5011
|
this.suppressCursorSync = !1;
|
|
5009
5012
|
}
|
|
5010
|
-
this.visualSelection.deactivate()
|
|
5013
|
+
this.visualSelection.deactivate();
|
|
5014
|
+
const f = this.viewport.applyScrolloff(o), h = this.nowMs();
|
|
5015
|
+
!f && h > this.suppressCursorRevealUntilMs && this.editor.revealPositionInCenterIfOutsideViewport(o);
|
|
5011
5016
|
}
|
|
5012
5017
|
this.requestSearchHighlightRefresh();
|
|
5013
5018
|
}
|