@monaco-neovim-wasm/lib 0.1.10 → 0.1.11
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/monaco-neovim-wasm.es.js +385 -349
- package/dist/monacoNeovim.d.ts +0 -1
- package/dist/neovimWasmSession.d.ts +1 -0
- package/package.json +2 -2
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as g from "monaco-editor";
|
|
2
|
-
class
|
|
2
|
+
class V {
|
|
3
3
|
buffer;
|
|
4
4
|
ctrl;
|
|
5
5
|
data;
|
|
6
6
|
capacity;
|
|
7
|
-
constructor(t =
|
|
7
|
+
constructor(t = N) {
|
|
8
8
|
this.capacity = Math.max(8 * 1024, t | 0), this.buffer = new SharedArrayBuffer(8 + this.capacity), this.ctrl = new Int32Array(this.buffer, 0, 2), this.data = new Uint8Array(this.buffer, 8), Atomics.store(this.ctrl, 0, 0), Atomics.store(this.ctrl, 1, 0);
|
|
9
9
|
}
|
|
10
10
|
push(t) {
|
|
@@ -12,19 +12,19 @@ class U {
|
|
|
12
12
|
if (t instanceof Uint8Array ? e = t : t instanceof ArrayBuffer || t instanceof SharedArrayBuffer ? e = new Uint8Array(t) : e = new Uint8Array(t), !e.byteLength) return !0;
|
|
13
13
|
const i = Atomics.load(this.ctrl, 0), s = Atomics.load(this.ctrl, 1), n = s >= i ? s - i : this.capacity - (i - s), r = this.capacity - n - 1;
|
|
14
14
|
if (e.byteLength > r) return !1;
|
|
15
|
-
const
|
|
16
|
-
return e.byteLength <=
|
|
15
|
+
const a = this.capacity - s;
|
|
16
|
+
return e.byteLength <= a ? (this.data.set(e, s), Atomics.store(this.ctrl, 1, (s + e.byteLength) % this.capacity)) : (this.data.set(e.subarray(0, a), s), this.data.set(e.subarray(a), 0), Atomics.store(this.ctrl, 1, e.byteLength - a)), Atomics.notify(this.ctrl, 1), !0;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
19
|
-
const
|
|
20
|
-
function
|
|
21
|
-
return new
|
|
19
|
+
const N = 262144;
|
|
20
|
+
function U(o = N) {
|
|
21
|
+
return new V(o);
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function R(o) {
|
|
24
24
|
const t = [];
|
|
25
|
-
return
|
|
25
|
+
return E(o, t), new Uint8Array(t);
|
|
26
26
|
}
|
|
27
|
-
function
|
|
27
|
+
function E(o, t) {
|
|
28
28
|
if (o == null) {
|
|
29
29
|
t.push(192);
|
|
30
30
|
return;
|
|
@@ -53,12 +53,12 @@ function T(o, t) {
|
|
|
53
53
|
j(o, t);
|
|
54
54
|
return;
|
|
55
55
|
}
|
|
56
|
-
if (
|
|
57
|
-
|
|
56
|
+
if (Y(o)) {
|
|
57
|
+
J(o, t);
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
60
|
if (typeof o == "object") {
|
|
61
|
-
|
|
61
|
+
X(o, t);
|
|
62
62
|
return;
|
|
63
63
|
}
|
|
64
64
|
throw new Error("Unsupported type in msgpack encode");
|
|
@@ -108,24 +108,24 @@ function G(o, t) {
|
|
|
108
108
|
const e = o.length;
|
|
109
109
|
e <= 15 ? t.push(144 | e) : e <= 65535 ? t.push(220, e >> 8 & 255, e & 255) : t.push(221, e >> 24 & 255, e >> 16 & 255, e >> 8 & 255, e & 255);
|
|
110
110
|
for (const i of o)
|
|
111
|
-
|
|
111
|
+
E(i, t);
|
|
112
112
|
}
|
|
113
|
-
function
|
|
113
|
+
function X(o, t) {
|
|
114
114
|
const e = Object.keys(o), i = e.length;
|
|
115
115
|
i <= 15 ? t.push(128 | i) : i <= 65535 ? t.push(222, i >> 8 & 255, i & 255) : t.push(223, i >> 24 & 255, i >> 16 & 255, i >> 8 & 255, i & 255);
|
|
116
116
|
for (const s of e)
|
|
117
|
-
|
|
117
|
+
E(s, t), E(o[s], t);
|
|
118
118
|
}
|
|
119
|
-
function
|
|
119
|
+
function J(o, t) {
|
|
120
120
|
const e = o.data.length;
|
|
121
121
|
e === 1 ? t.push(212, o.type) : e === 2 ? t.push(213, o.type) : e === 4 ? t.push(214, o.type) : e === 8 ? t.push(215, o.type) : e === 16 ? t.push(216, o.type) : t.push(199, e, o.type);
|
|
122
122
|
for (let i = 0; i < e; i += 1)
|
|
123
123
|
t.push(o.data[i]);
|
|
124
124
|
}
|
|
125
|
-
function
|
|
125
|
+
function Y(o) {
|
|
126
126
|
return !!(o && typeof o == "object" && typeof o.type == "number" && o.data instanceof Uint8Array);
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function Z() {
|
|
129
129
|
return typeof SharedArrayBuffer < "u" && typeof crossOriginIsolated < "u" && crossOriginIsolated;
|
|
130
130
|
}
|
|
131
131
|
function ee(o) {
|
|
@@ -140,6 +140,7 @@ class te {
|
|
|
140
140
|
pending = /* @__PURE__ */ new Map();
|
|
141
141
|
workerExited = !1;
|
|
142
142
|
workerExitCode = null;
|
|
143
|
+
workerFatalError = null;
|
|
143
144
|
inputQueue = [];
|
|
144
145
|
inputQueueHead = 0;
|
|
145
146
|
inputQueuedBytes = 0;
|
|
@@ -149,7 +150,7 @@ class te {
|
|
|
149
150
|
worker: t.worker ?? null,
|
|
150
151
|
workerUrl: t.workerUrl ?? null,
|
|
151
152
|
createWorker: t.createWorker ?? null,
|
|
152
|
-
sharedInputBytes: t.sharedInputBytes ??
|
|
153
|
+
sharedInputBytes: t.sharedInputBytes ?? N,
|
|
153
154
|
inputMode: t.inputMode ?? "shared",
|
|
154
155
|
rpcTimeoutMs: t.rpcTimeoutMs ?? 8e3,
|
|
155
156
|
maxQueuedBytes: t.maxQueuedBytes ?? 4 * 1024 * 1024,
|
|
@@ -167,13 +168,32 @@ class te {
|
|
|
167
168
|
return this.workerExitCode;
|
|
168
169
|
}
|
|
169
170
|
async start(t) {
|
|
170
|
-
const { cols: e, rows: i, wasmPath: s, runtimePath: n, env: r, files:
|
|
171
|
-
if (this.inputMode = t.inputMode ?? this.init.inputMode, this.inputMode === "shared" && !
|
|
171
|
+
const { cols: e, rows: i, wasmPath: s, runtimePath: n, env: r, files: a } = t;
|
|
172
|
+
if (this.inputMode = t.inputMode ?? this.init.inputMode, this.inputMode === "shared" && !Z())
|
|
172
173
|
throw new Error('SharedArrayBuffer is required for inputMode="shared"; serve with COOP/COEP so crossOriginIsolated is true, or use inputMode="message" with the asyncify worker.');
|
|
173
|
-
const
|
|
174
|
-
if (this.stop({ terminate: !this.init.reuseWorker, silent: !0 }), this.sharedInput = this.inputMode === "shared" ?
|
|
175
|
-
this.worker.onmessage = (
|
|
176
|
-
const
|
|
174
|
+
const u = this.worker;
|
|
175
|
+
if (this.stop({ terminate: !this.init.reuseWorker, silent: !0 }), this.sharedInput = this.inputMode === "shared" ? U(this.init.sharedInputBytes) : null, this.workerExited = !1, this.workerExitCode = null, this.workerFatalError = null, this.reqId = 1, this.pending.clear(), this.init.worker ? this.worker = this.init.worker : this.init.createWorker ? this.worker = this.init.createWorker() : this.init.reuseWorker && u ? this.worker = u : this.worker = this.init.workerUrl ? new Worker(this.init.workerUrl, { type: "module" }) : null, !this.worker) throw new Error("worker/workerUrl is required");
|
|
176
|
+
this.worker.onmessage = (l) => this.handleWorkerMessage(l.data);
|
|
177
|
+
const d = (l) => {
|
|
178
|
+
if (!this.workerExited) {
|
|
179
|
+
if (this.workerFatalError = l, this.workerExited = !0, this.workerExitCode = 1, this.pending.size) {
|
|
180
|
+
const c = new Error(l);
|
|
181
|
+
this.pending.forEach((h) => h.reject(c)), this.pending.clear();
|
|
182
|
+
}
|
|
183
|
+
try {
|
|
184
|
+
this.init.handlers.onStartError?.(l);
|
|
185
|
+
} catch {
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
this.worker.onerror = (l) => {
|
|
190
|
+
const c = l?.message ? `worker error: ${l.message}` : "worker error", h = l?.error?.stack;
|
|
191
|
+
d(h ? `${c}
|
|
192
|
+
${h}` : c);
|
|
193
|
+
}, this.worker.onmessageerror = () => {
|
|
194
|
+
d("worker messageerror");
|
|
195
|
+
};
|
|
196
|
+
const f = {
|
|
177
197
|
type: "start",
|
|
178
198
|
cols: Number(e) || 80,
|
|
179
199
|
rows: Number(i) || 24,
|
|
@@ -181,12 +201,12 @@ class te {
|
|
|
181
201
|
runtimePath: String(n ?? ""),
|
|
182
202
|
inputBuffer: this.sharedInput?.buffer ?? null,
|
|
183
203
|
env: r ?? void 0,
|
|
184
|
-
files:
|
|
204
|
+
files: a ?? void 0
|
|
185
205
|
};
|
|
186
206
|
try {
|
|
187
|
-
this.worker.postMessage(
|
|
207
|
+
this.worker.postMessage(f, []);
|
|
188
208
|
} catch {
|
|
189
|
-
this.worker.postMessage(
|
|
209
|
+
this.worker.postMessage(f);
|
|
190
210
|
}
|
|
191
211
|
}
|
|
192
212
|
stop(t = {}) {
|
|
@@ -211,7 +231,7 @@ class te {
|
|
|
211
231
|
}
|
|
212
232
|
notify(t, e = []) {
|
|
213
233
|
if (!this.worker || this.workerExited) return;
|
|
214
|
-
const i =
|
|
234
|
+
const i = R([2, t, e]);
|
|
215
235
|
this.postInput(i);
|
|
216
236
|
}
|
|
217
237
|
call(t, e = []) {
|
|
@@ -221,32 +241,41 @@ class te {
|
|
|
221
241
|
return;
|
|
222
242
|
}
|
|
223
243
|
if (this.workerExited) {
|
|
224
|
-
const
|
|
225
|
-
s(new Error(
|
|
244
|
+
const a = this.workerExitCode, u = this.workerFatalError ? `: ${this.workerFatalError}` : "";
|
|
245
|
+
s(new Error(a != null ? `nvim exited (${a})${u}` : `nvim exited${u}`));
|
|
226
246
|
return;
|
|
227
247
|
}
|
|
228
248
|
const n = this.reqId++;
|
|
229
249
|
this.pending.set(n, { resolve: i, reject: s, ts: Date.now(), method: t });
|
|
230
|
-
const r =
|
|
250
|
+
const r = R([0, n, t, e]);
|
|
231
251
|
this.postInput(r), setTimeout(() => {
|
|
232
|
-
this.pending.has(n) && (this.pending.delete(n), s(new Error(this.workerExited ? this.workerExitCode != null ? `nvim exited (${this.workerExitCode})` : "nvim exited" : `rpc timeout: ${t}`)));
|
|
252
|
+
this.pending.has(n) && (this.pending.delete(n), s(new Error(this.workerExited ? this.workerExitCode != null ? `nvim exited (${this.workerExitCode})${this.workerFatalError ? `: ${this.workerFatalError}` : ""}` : `nvim exited${this.workerFatalError ? `: ${this.workerFatalError}` : ""}` : `rpc timeout: ${t}`)));
|
|
233
253
|
}, this.init.rpcTimeoutMs);
|
|
234
254
|
});
|
|
235
255
|
}
|
|
236
256
|
async waitForApi() {
|
|
237
|
-
const e = Math.min(Math.max(this.init.rpcTimeoutMs * 2,
|
|
238
|
-
for (
|
|
257
|
+
const e = Math.min(Math.max(this.init.rpcTimeoutMs * 2, 15e3), 9e4), i = Date.now() + e;
|
|
258
|
+
for (; Date.now() < i; ) {
|
|
259
|
+
if (this.workerExited) {
|
|
260
|
+
const s = this.workerExitCode, n = this.workerFatalError ? `: ${this.workerFatalError}` : "";
|
|
261
|
+
throw new Error(s != null ? `nvim exited (${s})${n}` : `nvim exited${n}`);
|
|
262
|
+
}
|
|
239
263
|
try {
|
|
240
264
|
await this.call("nvim_get_api_info", []);
|
|
241
265
|
return;
|
|
242
266
|
} catch {
|
|
243
|
-
|
|
267
|
+
if (this.workerExited) {
|
|
268
|
+
const n = this.workerExitCode, r = this.workerFatalError ? `: ${this.workerFatalError}` : "";
|
|
269
|
+
throw new Error(n != null ? `nvim exited (${n})${r}` : `nvim exited${r}`);
|
|
270
|
+
}
|
|
271
|
+
await new Promise((n) => setTimeout(n, 300));
|
|
244
272
|
}
|
|
273
|
+
}
|
|
245
274
|
throw new Error("nvim_get_api_info timed out");
|
|
246
275
|
}
|
|
247
276
|
respond(t, e, i) {
|
|
248
277
|
if (!this.worker || this.workerExited) return;
|
|
249
|
-
const s =
|
|
278
|
+
const s = R([1, t, e, i]);
|
|
250
279
|
this.postInput(s);
|
|
251
280
|
}
|
|
252
281
|
handleWorkerMessage(t) {
|
|
@@ -308,8 +337,8 @@ class te {
|
|
|
308
337
|
if (e === "exit") {
|
|
309
338
|
const i = t, s = i.code, n = i.lastStderr;
|
|
310
339
|
if (this.workerExited = !0, this.workerExitCode = s, this.pending.size) {
|
|
311
|
-
const r = n ? `: ${n.trim()}` : "",
|
|
312
|
-
this.pending.forEach((
|
|
340
|
+
const r = n ? `: ${n.trim()}` : "", a = new Error(`nvim exited (${s})${r}`);
|
|
341
|
+
this.pending.forEach((u) => u.reject(a)), this.pending.clear();
|
|
313
342
|
}
|
|
314
343
|
try {
|
|
315
344
|
this.init.handlers.onExit?.(s, n);
|
|
@@ -360,18 +389,18 @@ class te {
|
|
|
360
389
|
} else {
|
|
361
390
|
let e = 0, i = 0;
|
|
362
391
|
for (let r = this.inputQueueHead; r < this.inputQueue.length; r += 1) {
|
|
363
|
-
const
|
|
364
|
-
if (
|
|
365
|
-
if (i > 0 && e +
|
|
366
|
-
e +=
|
|
392
|
+
const a = this.inputQueue[r];
|
|
393
|
+
if (a?.byteLength) {
|
|
394
|
+
if (i > 0 && e + a.byteLength > 262144) break;
|
|
395
|
+
e += a.byteLength, i += 1;
|
|
367
396
|
}
|
|
368
397
|
}
|
|
369
398
|
if (i <= 0 || e <= 0) return;
|
|
370
399
|
const s = new Uint8Array(e);
|
|
371
400
|
let n = 0;
|
|
372
401
|
for (let r = 0; r < i; r += 1) {
|
|
373
|
-
const
|
|
374
|
-
s.set(
|
|
402
|
+
const a = this.inputQueue[this.inputQueueHead + r];
|
|
403
|
+
s.set(a, n), n += a.byteLength;
|
|
375
404
|
}
|
|
376
405
|
this.inputQueueHead += i, this.inputQueuedBytes -= e, this.postStdin(s);
|
|
377
406
|
}
|
|
@@ -697,7 +726,7 @@ local function get_selections(win)
|
|
|
697
726
|
end
|
|
698
727
|
|
|
699
728
|
return get_selections(...)
|
|
700
|
-
`,
|
|
729
|
+
`, ae = `
|
|
701
730
|
local api, fn = vim.api, vim.fn
|
|
702
731
|
|
|
703
732
|
local function get_visible_range(s, e)
|
|
@@ -786,7 +815,7 @@ end
|
|
|
786
815
|
|
|
787
816
|
return run(...)
|
|
788
817
|
`;
|
|
789
|
-
class
|
|
818
|
+
class le {
|
|
790
819
|
editor;
|
|
791
820
|
opts;
|
|
792
821
|
session = null;
|
|
@@ -850,7 +879,6 @@ class ae {
|
|
|
850
879
|
compositionActive = !1;
|
|
851
880
|
pendingResyncAfterComposition = !1;
|
|
852
881
|
ignoreNextInputEvent = !1;
|
|
853
|
-
ignoreNvimBufLinesUntil = 0;
|
|
854
882
|
exitingInsertMode = !1;
|
|
855
883
|
pendingKeysAfterExit = "";
|
|
856
884
|
exitInsertTimer = null;
|
|
@@ -898,7 +926,7 @@ class ae {
|
|
|
898
926
|
const e = String(t ?? "");
|
|
899
927
|
if (!e) return;
|
|
900
928
|
const i = typeof performance < "u" && performance.now ? performance.now() : Date.now();
|
|
901
|
-
e.length > 1 && e === this.lastImeCommitText && i - this.lastImeCommitAt < 60 || (this.lastImeCommitText = e, this.lastImeCommitAt = i, this.sendInput(
|
|
929
|
+
e.length > 1 && e === this.lastImeCommitText && i - this.lastImeCommitAt < 60 || (this.lastImeCommitText = e, this.lastImeCommitAt = i, this.sendInput(k(e, !0)));
|
|
902
930
|
}
|
|
903
931
|
constructor(t, e = {}) {
|
|
904
932
|
this.editor = t, this.opts = {
|
|
@@ -910,7 +938,7 @@ class ae {
|
|
|
910
938
|
inputMode: e.inputMode ?? "shared",
|
|
911
939
|
env: e.env,
|
|
912
940
|
files: e.files,
|
|
913
|
-
sharedInputBytes: e.sharedInputBytes ??
|
|
941
|
+
sharedInputBytes: e.sharedInputBytes ?? N,
|
|
914
942
|
cols: e.cols ?? 120,
|
|
915
943
|
rows: e.rows ?? 40,
|
|
916
944
|
minCols: e.minCols ?? 20,
|
|
@@ -1073,7 +1101,7 @@ class ae {
|
|
|
1073
1101
|
this.sendNotify("nvim_input", [String(t ?? "")]);
|
|
1074
1102
|
}
|
|
1075
1103
|
type(t, e = !0) {
|
|
1076
|
-
const i =
|
|
1104
|
+
const i = k(String(t ?? ""), e);
|
|
1077
1105
|
i && this.sendNotify("nvim_input", [i]);
|
|
1078
1106
|
}
|
|
1079
1107
|
paste(t) {
|
|
@@ -1086,8 +1114,8 @@ class ae {
|
|
|
1086
1114
|
const r = await this.rpcCall("nvim_exec_lua", [i, s]);
|
|
1087
1115
|
return this.execLuaAvailable = !0, r;
|
|
1088
1116
|
} catch (r) {
|
|
1089
|
-
const
|
|
1090
|
-
if (
|
|
1117
|
+
const a = r?.message || String(r);
|
|
1118
|
+
if (a.includes("Invalid method") && a.includes("nvim_exec_lua"))
|
|
1091
1119
|
this.execLuaAvailable = !1;
|
|
1092
1120
|
else
|
|
1093
1121
|
throw r;
|
|
@@ -1176,8 +1204,8 @@ end)(unpack(_A))`;
|
|
|
1176
1204
|
}
|
|
1177
1205
|
computeGridSize() {
|
|
1178
1206
|
try {
|
|
1179
|
-
const t = this.editor.getLayoutInfo(), e = Math.max(0, Number(t?.contentWidth ?? t?.width ?? 0) || 0), i = Math.max(0, Number(t?.contentHeight ?? t?.height ?? 0) || 0), s = this.editor.getOption(g.editor.EditorOption.fontInfo), n = Math.max(1, Number(s?.typicalHalfwidthCharacterWidth ?? s?.maxDigitWidth ?? 0) || 0), r = Math.max(1, Number(s?.lineHeight ?? 0) || 0),
|
|
1180
|
-
if (Number.isFinite(
|
|
1207
|
+
const t = this.editor.getLayoutInfo(), e = Math.max(0, Number(t?.contentWidth ?? t?.width ?? 0) || 0), i = Math.max(0, Number(t?.contentHeight ?? t?.height ?? 0) || 0), s = this.editor.getOption(g.editor.EditorOption.fontInfo), n = Math.max(1, Number(s?.typicalHalfwidthCharacterWidth ?? s?.maxDigitWidth ?? 0) || 0), r = Math.max(1, Number(s?.lineHeight ?? 0) || 0), a = Math.max(this.opts.minCols, Math.floor(e / n)), u = Math.max(this.opts.minRows, Math.floor(i / r));
|
|
1208
|
+
if (Number.isFinite(a) && Number.isFinite(u) && a > 0 && u > 0) return { cols: a, rows: u };
|
|
1181
1209
|
} catch {
|
|
1182
1210
|
}
|
|
1183
1211
|
return { cols: this.opts.cols, rows: this.opts.rows };
|
|
@@ -1220,10 +1248,10 @@ end)(unpack(_A))`;
|
|
|
1220
1248
|
const e = this.editor.getModel();
|
|
1221
1249
|
if (!e) return;
|
|
1222
1250
|
const i = this.editor.getSelection(), n = (i && !i.isEmpty() ? i.getStartPosition() : null) ?? this.editor.getPosition() ?? this.lastCursorPos ?? new g.Position(1, 1), r = String(t).split(/\r?\n/);
|
|
1223
|
-
let
|
|
1224
|
-
r.length <= 1 ?
|
|
1225
|
-
const
|
|
1226
|
-
this.optimisticCursorPrevPos = f, this.optimisticCursorPos =
|
|
1251
|
+
let a = n.lineNumber, u = n.column;
|
|
1252
|
+
r.length <= 1 ? u += Array.from(r[0] ?? "").length : (a += r.length - 1, u = 1 + Array.from(r[r.length - 1] ?? "").length);
|
|
1253
|
+
const d = e.validatePosition(new g.Position(a, u)), f = this.editor.getPosition() ?? this.lastCursorPos ?? n;
|
|
1254
|
+
this.optimisticCursorPrevPos = f, this.optimisticCursorPos = d, this.optimisticCursorUntil = (typeof performance < "u" && performance.now ? performance.now() : Date.now()) + 120, this.lastCursorPos = d, !this.compositionActive && (this.suppressCursorSync = !0, this.editor.setPosition(d), this.suppressCursorSync = !1);
|
|
1227
1255
|
}
|
|
1228
1256
|
positionPreedit() {
|
|
1229
1257
|
if (!this.preeditEl || !this.preeditVisible) return;
|
|
@@ -1359,11 +1387,11 @@ end)(unpack(_A))`;
|
|
|
1359
1387
|
try {
|
|
1360
1388
|
const r = this.ensureActiveState();
|
|
1361
1389
|
if (r) {
|
|
1362
|
-
const
|
|
1363
|
-
r.name = typeof
|
|
1390
|
+
const a = await this.rpcCall("nvim_buf_get_name", [e]);
|
|
1391
|
+
r.name = typeof a == "string" ? a : "", r.name && this.buffersByName.set(r.name, e);
|
|
1364
1392
|
try {
|
|
1365
|
-
const
|
|
1366
|
-
r.filetype = typeof
|
|
1393
|
+
const u = await this.rpcCall("nvim_buf_get_option", [e, "filetype"]);
|
|
1394
|
+
r.filetype = typeof u == "string" ? u : "";
|
|
1367
1395
|
} catch {
|
|
1368
1396
|
}
|
|
1369
1397
|
}
|
|
@@ -1435,11 +1463,11 @@ end)(unpack(_A))`;
|
|
|
1435
1463
|
if (t === "monaco_cursor") {
|
|
1436
1464
|
const [i, s] = e, n = B(this.editor, Number(i), Number(s));
|
|
1437
1465
|
if (this.delegateInsertToMonaco) {
|
|
1438
|
-
const r = this.editor.getModel(),
|
|
1439
|
-
this.lastCursorPos =
|
|
1466
|
+
const r = this.editor.getModel(), a = r ? r.validatePosition(new g.Position(n.line, n.col)) : new g.Position(n.line, n.col);
|
|
1467
|
+
this.lastCursorPos = a;
|
|
1440
1468
|
return;
|
|
1441
1469
|
}
|
|
1442
|
-
this.updateCursor(n.line, n.col),
|
|
1470
|
+
this.updateCursor(n.line, n.col), w(this.lastMode) && this.scheduleVisualSelectionRefresh();
|
|
1443
1471
|
return;
|
|
1444
1472
|
}
|
|
1445
1473
|
if (t === "monaco_mode") {
|
|
@@ -1453,44 +1481,43 @@ end)(unpack(_A))`;
|
|
|
1453
1481
|
return;
|
|
1454
1482
|
}
|
|
1455
1483
|
if (t === "nvim_buf_lines_event") {
|
|
1456
|
-
const [i, s, n, r,
|
|
1457
|
-
if (!
|
|
1458
|
-
const
|
|
1459
|
-
if (!
|
|
1460
|
-
if (this.bufHandle != null &&
|
|
1484
|
+
const [i, s, n, r, a] = e, u = x(i);
|
|
1485
|
+
if (!u) return;
|
|
1486
|
+
const d = this.bufHandle != null && u === this.bufHandle ? this.ensureActiveState() : this.buffers.get(u) ?? null;
|
|
1487
|
+
if (!d) return;
|
|
1488
|
+
if (this.bufHandle != null && u === this.bufHandle && this.compositionActive) {
|
|
1461
1489
|
this.pendingResyncAfterComposition = !0;
|
|
1462
1490
|
return;
|
|
1463
1491
|
}
|
|
1464
|
-
const f =
|
|
1465
|
-
if (f && Number.isInteger(
|
|
1492
|
+
const f = d.model, l = Number(n), c = Number(r), h = Array.isArray(a) ? a.map((p) => String(p ?? "")) : null;
|
|
1493
|
+
if (f && Number.isInteger(l) && Number.isInteger(c) && l >= 0 && c >= l && h)
|
|
1466
1494
|
try {
|
|
1467
|
-
const p = this.bufHandle != null &&
|
|
1495
|
+
const p = this.bufHandle != null && u === this.bufHandle && this.editor.getModel() === f;
|
|
1468
1496
|
if (p && this.delegateInsertToMonaco) {
|
|
1469
|
-
const y = this.computeLinePatch(f,
|
|
1497
|
+
const y = this.computeLinePatch(f, l, c, h);
|
|
1470
1498
|
let b = !1;
|
|
1471
1499
|
try {
|
|
1472
1500
|
b = f.getValueInRange(y.range) === y.text;
|
|
1473
1501
|
} catch {
|
|
1474
1502
|
}
|
|
1475
1503
|
if (!b) {
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
this.applyLinePatchToModel(f, a, u, d);
|
|
1504
|
+
if (d.pendingFullSync || d.pendingBufEdits.length) return;
|
|
1505
|
+
this.applyLinePatchToModel(f, l, c, h);
|
|
1479
1506
|
try {
|
|
1480
|
-
|
|
1507
|
+
d.shadowLines = f.getLinesContent();
|
|
1481
1508
|
} catch {
|
|
1482
1509
|
}
|
|
1483
1510
|
}
|
|
1484
|
-
} else p ? this.applyLinePatch(f,
|
|
1511
|
+
} else p ? this.applyLinePatch(f, l, c, h) : this.applyLinePatchToModel(f, l, c, h);
|
|
1485
1512
|
} catch {
|
|
1486
1513
|
}
|
|
1487
1514
|
else
|
|
1488
1515
|
try {
|
|
1489
|
-
const p = await this.rpcCall("nvim_buf_get_lines", [
|
|
1490
|
-
this.bufHandle != null &&
|
|
1516
|
+
const p = await this.rpcCall("nvim_buf_get_lines", [u, 0, -1, !1]), y = Array.isArray(p) ? p : [""];
|
|
1517
|
+
this.bufHandle != null && u === this.bufHandle && this.editor.getModel() === f ? this.applyBuffer(y) : this.setModelText(f, y);
|
|
1491
1518
|
} catch {
|
|
1492
1519
|
}
|
|
1493
|
-
this.bufHandle != null &&
|
|
1520
|
+
this.bufHandle != null && u === this.bufHandle && w(this.lastMode) && this.scheduleVisualSelectionRefresh();
|
|
1494
1521
|
} else if (t === "nvim_buf_detach_event") {
|
|
1495
1522
|
const i = x(e?.[0]);
|
|
1496
1523
|
if (i && this.buffers.has(i)) {
|
|
@@ -1506,12 +1533,12 @@ end)(unpack(_A))`;
|
|
|
1506
1533
|
} else t === "redraw" && this.handleRedraw(e);
|
|
1507
1534
|
}
|
|
1508
1535
|
computeLinePatch(t, e, i, s) {
|
|
1509
|
-
const n = t.getLineCount(), r = Math.min(e, n),
|
|
1510
|
-
let
|
|
1536
|
+
const n = t.getLineCount(), r = Math.min(e, n), a = Math.min(i, n), u = new g.Position(n, t.getLineMaxColumn(n)), f = a >= n && s.length === 0 && r > 0 ? new g.Position(r, t.getLineMaxColumn(r)) : r < n ? new g.Position(r + 1, 1) : u, l = a < n ? new g.Position(a + 1, 1) : u;
|
|
1537
|
+
let c = s.join(`
|
|
1511
1538
|
`);
|
|
1512
|
-
return e >= n && i >= n && s.length > 0 && (
|
|
1513
|
-
${
|
|
1514
|
-
`), { range: new g.Range(f.lineNumber, f.column,
|
|
1539
|
+
return e >= n && i >= n && s.length > 0 && (c = `
|
|
1540
|
+
${c}`), i < n && s.length > 0 && (c += `
|
|
1541
|
+
`), { range: new g.Range(f.lineNumber, f.column, l.lineNumber, l.column), text: c };
|
|
1515
1542
|
}
|
|
1516
1543
|
applyLinePatch(t, e, i, s) {
|
|
1517
1544
|
const n = this.lastCursorPos ?? this.editor.getPosition() ?? new g.Position(1, 1), r = this.computeLinePatch(t, e, i, s);
|
|
@@ -1520,10 +1547,10 @@ ${u}`), i < n && s.length > 0 && (u += `
|
|
|
1520
1547
|
} catch {
|
|
1521
1548
|
}
|
|
1522
1549
|
if (this.suppressCursorSync = !0, this.applyingFromNvim = !0, t.applyEdits([{ range: r.range, text: r.text }]), this.applyingFromNvim = !1, n && this.editor.setPosition(n), this.suppressCursorSync = !1, this.delegateInsertToMonaco) {
|
|
1523
|
-
const
|
|
1524
|
-
if (
|
|
1550
|
+
const a = this.getActiveState();
|
|
1551
|
+
if (a && a.model === t)
|
|
1525
1552
|
try {
|
|
1526
|
-
|
|
1553
|
+
a.shadowLines = t.getLinesContent();
|
|
1527
1554
|
} catch {
|
|
1528
1555
|
}
|
|
1529
1556
|
}
|
|
@@ -1597,7 +1624,7 @@ ${u}`), i < n && s.length > 0 && (u += `
|
|
|
1597
1624
|
this.cmdlineEl.textContent = this.cmdlineTextRaw, this.cmdlineCursorByte = null;
|
|
1598
1625
|
return;
|
|
1599
1626
|
}
|
|
1600
|
-
const e = this.cmdlineTextRaw, i = Math.max(0, Math.min(Number(t) || 0,
|
|
1627
|
+
const e = this.cmdlineTextRaw, i = Math.max(0, Math.min(Number(t) || 0, A(e))), s = Math.max(0, Math.min(e.length, S(e, i)));
|
|
1601
1628
|
this.cmdlineCursorByte = i, this.cmdlineEl.textContent = `${e.slice(0, s)}▏${e.slice(s)}`;
|
|
1602
1629
|
}
|
|
1603
1630
|
setMessage(t) {
|
|
@@ -1633,8 +1660,8 @@ ${u}`), i < n && s.length > 0 && (u += `
|
|
|
1633
1660
|
n.style.padding = "2px 10px", n.style.display = "flex", n.style.gap = "10px", n.style.justifyContent = "space-between", n.style.background = i === e ? "rgba(255,255,255,0.12)" : "transparent";
|
|
1634
1661
|
const r = document.createElement("span");
|
|
1635
1662
|
r.textContent = s.word ?? "";
|
|
1636
|
-
const
|
|
1637
|
-
|
|
1663
|
+
const a = document.createElement("span");
|
|
1664
|
+
a.style.opacity = "0.7", a.textContent = s.menu ?? s.kind ?? "", n.appendChild(r), n.appendChild(a), this.popupEl.appendChild(n);
|
|
1638
1665
|
}
|
|
1639
1666
|
this.popupEl.style.display = "block";
|
|
1640
1667
|
}
|
|
@@ -1662,10 +1689,10 @@ ${u}`), i < n && s.length > 0 && (u += `
|
|
|
1662
1689
|
} catch {
|
|
1663
1690
|
}
|
|
1664
1691
|
if (i === "wrappedLine" && (e === "down" || e === "up")) {
|
|
1665
|
-
const
|
|
1666
|
-
for (let
|
|
1692
|
+
const a = e === "down" ? "cursorDown" : "cursorUp";
|
|
1693
|
+
for (let u = 0; u < s; u += 1)
|
|
1667
1694
|
try {
|
|
1668
|
-
this.editor.trigger("monaco-neovim-wasm",
|
|
1695
|
+
this.editor.trigger("monaco-neovim-wasm", a, null);
|
|
1669
1696
|
} catch {
|
|
1670
1697
|
}
|
|
1671
1698
|
return !0;
|
|
@@ -1694,46 +1721,46 @@ ${u}`), i < n && s.length > 0 && (u += `
|
|
|
1694
1721
|
} catch {
|
|
1695
1722
|
}
|
|
1696
1723
|
if (r <= 0) return !1;
|
|
1697
|
-
const
|
|
1724
|
+
const a = () => {
|
|
1698
1725
|
try {
|
|
1699
1726
|
this.editor.revealPositionInCenterIfOutsideViewport(i);
|
|
1700
1727
|
} catch {
|
|
1701
1728
|
}
|
|
1702
1729
|
};
|
|
1703
|
-
let
|
|
1730
|
+
let u = null;
|
|
1704
1731
|
try {
|
|
1705
|
-
|
|
1732
|
+
u = this.editor.getScrolledVisiblePosition(i);
|
|
1706
1733
|
} catch {
|
|
1707
1734
|
}
|
|
1708
|
-
if (!
|
|
1709
|
-
|
|
1735
|
+
if (!u) {
|
|
1736
|
+
a();
|
|
1710
1737
|
try {
|
|
1711
|
-
|
|
1738
|
+
u = this.editor.getScrolledVisiblePosition(i);
|
|
1712
1739
|
} catch {
|
|
1713
1740
|
}
|
|
1714
1741
|
}
|
|
1715
|
-
if (!
|
|
1716
|
-
const
|
|
1717
|
-
let
|
|
1718
|
-
if (f < n ?
|
|
1742
|
+
if (!u || !Number.isFinite(u.top) || !Number.isFinite(u.height)) return !1;
|
|
1743
|
+
const d = this.editor.getScrollTop(), f = u.top, l = u.top + u.height, c = Math.max(0, r - n);
|
|
1744
|
+
let h = 0;
|
|
1745
|
+
if (f < n ? h = f - n : l > c && (h = l - c), !h) return !1;
|
|
1719
1746
|
try {
|
|
1720
|
-
this.editor.setScrollTop(Math.max(0,
|
|
1747
|
+
this.editor.setScrollTop(Math.max(0, d + h));
|
|
1721
1748
|
} catch {
|
|
1722
1749
|
}
|
|
1723
1750
|
return !0;
|
|
1724
1751
|
}
|
|
1725
1752
|
applyMonacoScroll(t) {
|
|
1726
|
-
const e = typeof t.by == "string" ? t.by : "", i = typeof t.direction == "string" ? t.direction : "", s = Math.max(1, Number(t.value ?? 1) || 1), n = !!t.moveCursor, r = typeof t.cursorBy == "string" ? t.cursorBy : "wrappedLine",
|
|
1727
|
-
let
|
|
1728
|
-
if (e === "page")
|
|
1729
|
-
else if (e === "halfPage")
|
|
1730
|
-
else if (e === "line")
|
|
1753
|
+
const e = typeof t.by == "string" ? t.by : "", i = typeof t.direction == "string" ? t.direction : "", s = Math.max(1, Number(t.value ?? 1) || 1), n = !!t.moveCursor, r = typeof t.cursorBy == "string" ? t.cursorBy : "wrappedLine", a = Math.max(3, this.uiRows || this.opts.rows), u = this.editor.getOption(g.editor.EditorOption.fontInfo), d = Math.max(1, Number(u?.lineHeight ?? 0) || 0), f = Math.max(1, a - 2), l = Math.max(1, Math.floor(f / 2));
|
|
1754
|
+
let c = s;
|
|
1755
|
+
if (e === "page") c = f * s;
|
|
1756
|
+
else if (e === "halfPage") c = l * s;
|
|
1757
|
+
else if (e === "line") c = s;
|
|
1731
1758
|
else return !1;
|
|
1732
|
-
const
|
|
1733
|
-
if (!
|
|
1759
|
+
const h = i === "up" ? -1 : i === "down" ? 1 : 0;
|
|
1760
|
+
if (!h) return !1;
|
|
1734
1761
|
this.suppressCursorSync = !0;
|
|
1735
1762
|
try {
|
|
1736
|
-
const p = this.editor.getScrollTop(), y = Math.max(0, p +
|
|
1763
|
+
const p = this.editor.getScrollTop(), y = Math.max(0, p + h * c * d);
|
|
1737
1764
|
this.editor.setScrollTop(y);
|
|
1738
1765
|
} catch {
|
|
1739
1766
|
}
|
|
@@ -1741,9 +1768,9 @@ ${u}`), i < n && s.length > 0 && (u += `
|
|
|
1741
1768
|
if (n)
|
|
1742
1769
|
try {
|
|
1743
1770
|
this.applyMonacoCursorMove({
|
|
1744
|
-
to:
|
|
1771
|
+
to: h > 0 ? "down" : "up",
|
|
1745
1772
|
by: r,
|
|
1746
|
-
value:
|
|
1773
|
+
value: c
|
|
1747
1774
|
}), m = !0;
|
|
1748
1775
|
} catch {
|
|
1749
1776
|
}
|
|
@@ -1752,23 +1779,23 @@ ${u}`), i < n && s.length > 0 && (u += `
|
|
|
1752
1779
|
applyMonacoReveal(t) {
|
|
1753
1780
|
const e = typeof t.direction == "string" ? t.direction : "", i = !!t.resetCursor, s = this.editor.getPosition();
|
|
1754
1781
|
if (!s) return !1;
|
|
1755
|
-
const n = s.lineNumber, r = Math.max(1, this.uiRows || this.opts.rows),
|
|
1782
|
+
const n = s.lineNumber, r = Math.max(1, this.uiRows || this.opts.rows), a = this.editor.getOption(g.editor.EditorOption.fontInfo), u = Math.max(1, Number(a?.lineHeight ?? 0) || 0);
|
|
1756
1783
|
this.suppressCursorSync = !0;
|
|
1757
1784
|
try {
|
|
1758
1785
|
if (e === "top") {
|
|
1759
|
-
const
|
|
1760
|
-
this.editor.setScrollTop(
|
|
1786
|
+
const d = this.editor.getTopForLineNumber(n);
|
|
1787
|
+
this.editor.setScrollTop(d);
|
|
1761
1788
|
} else if (e === "center")
|
|
1762
1789
|
this.editor.revealLineInCenter(n);
|
|
1763
1790
|
else if (e === "bottom") {
|
|
1764
|
-
const
|
|
1791
|
+
const d = this.editor.getTopForLineNumber(n), f = Math.max(0, d - (r - 1) * u);
|
|
1765
1792
|
this.editor.setScrollTop(f);
|
|
1766
1793
|
}
|
|
1767
1794
|
if (i) {
|
|
1768
|
-
const
|
|
1769
|
-
if (
|
|
1770
|
-
const f =
|
|
1771
|
-
this.editor.setPosition(
|
|
1795
|
+
const d = this.editor.getModel();
|
|
1796
|
+
if (d) {
|
|
1797
|
+
const f = d.getLineContent(n) ?? "", l = /\S/.exec(f), c = l ? l.index + 1 : 1, h = d.validatePosition(new g.Position(n, c));
|
|
1798
|
+
this.editor.setPosition(h), this.lastCursorPos = h;
|
|
1772
1799
|
}
|
|
1773
1800
|
}
|
|
1774
1801
|
} catch {
|
|
@@ -1783,28 +1810,28 @@ ${u}`), i < n && s.length > 0 && (u += `
|
|
|
1783
1810
|
const s = Math.max(1, Number(t.value ?? 1) || 1);
|
|
1784
1811
|
let n = 1, r = i.getLineCount();
|
|
1785
1812
|
try {
|
|
1786
|
-
const
|
|
1787
|
-
|
|
1813
|
+
const c = this.editor.getVisibleRanges();
|
|
1814
|
+
c && c.length && (n = Math.min(...c.map((h) => h.startLineNumber)), r = Math.max(...c.map((h) => h.endLineNumber)));
|
|
1788
1815
|
} catch {
|
|
1789
1816
|
}
|
|
1790
1817
|
n = Math.max(1, Math.min(n, i.getLineCount())), r = Math.max(1, Math.min(r, i.getLineCount())), r < n && (r = n);
|
|
1791
|
-
let
|
|
1818
|
+
let a = n;
|
|
1792
1819
|
if (e === "top")
|
|
1793
|
-
|
|
1820
|
+
a = n + (s - 1);
|
|
1794
1821
|
else if (e === "middle")
|
|
1795
|
-
|
|
1822
|
+
a = Math.floor((n + r) / 2);
|
|
1796
1823
|
else if (e === "bottom")
|
|
1797
|
-
|
|
1824
|
+
a = r - (s - 1);
|
|
1798
1825
|
else
|
|
1799
1826
|
return;
|
|
1800
|
-
|
|
1801
|
-
const
|
|
1827
|
+
a = Math.max(n, Math.min(r, a));
|
|
1828
|
+
const u = i.getLineContent(a) ?? "", d = /\S/.exec(u), f = d ? d.index + 1 : 1, l = i.validatePosition(new g.Position(a, f));
|
|
1802
1829
|
this.suppressCursorSync = !0;
|
|
1803
1830
|
try {
|
|
1804
|
-
this.editor.setPosition(
|
|
1831
|
+
this.editor.setPosition(l);
|
|
1805
1832
|
} catch {
|
|
1806
1833
|
}
|
|
1807
|
-
this.lastCursorPos =
|
|
1834
|
+
this.lastCursorPos = l, this.suppressCursorSync = !1;
|
|
1808
1835
|
}
|
|
1809
1836
|
syncTabstopFromMonaco() {
|
|
1810
1837
|
const t = this.editor.getModel();
|
|
@@ -1838,17 +1865,17 @@ ${u}`), i < n && s.length > 0 && (u += `
|
|
|
1838
1865
|
continue;
|
|
1839
1866
|
}
|
|
1840
1867
|
if (i === "cmdline_show") {
|
|
1841
|
-
const r = n[0],
|
|
1868
|
+
const r = n[0], a = Math.max(0, Number(n[1] ?? 0) || 0), u = typeof n[2] == "string" ? n[2] : "", d = typeof n[3] == "string" ? n[3] : "", f = Math.max(0, Number(n[4] ?? 0) || 0), l = d || u || "", c = " ".repeat(f), h = T(r), m = `${c}${l}${h}`;
|
|
1842
1869
|
this.setCmdline(m);
|
|
1843
|
-
const p =
|
|
1870
|
+
const p = A(`${c}${l}`), y = A(h);
|
|
1844
1871
|
this.cmdlineCursorOffsetBytes = p, this.cmdlineCursorContentBytes = y;
|
|
1845
|
-
const b =
|
|
1872
|
+
const b = a <= y ? this.cmdlineCursorOffsetBytes + a : a;
|
|
1846
1873
|
this.setCmdlineCursor(b), this.scheduleSearchHighlightRefresh();
|
|
1847
1874
|
continue;
|
|
1848
1875
|
}
|
|
1849
1876
|
if (i === "cmdline_pos") {
|
|
1850
|
-
const r = Math.max(0, Number(n[0] ?? 0) || 0),
|
|
1851
|
-
this.setCmdlineCursor(
|
|
1877
|
+
const r = Math.max(0, Number(n[0] ?? 0) || 0), a = this.cmdlineCursorOffsetBytes > 0 && r <= this.cmdlineCursorContentBytes ? this.cmdlineCursorOffsetBytes + r : r;
|
|
1878
|
+
this.setCmdlineCursor(a), this.scheduleSearchHighlightRefresh();
|
|
1852
1879
|
continue;
|
|
1853
1880
|
}
|
|
1854
1881
|
if (i === "msg_clear") {
|
|
@@ -1856,17 +1883,17 @@ ${u}`), i < n && s.length > 0 && (u += `
|
|
|
1856
1883
|
continue;
|
|
1857
1884
|
}
|
|
1858
1885
|
if (i === "msg_show") {
|
|
1859
|
-
const r = typeof n[0] == "string" ? n[0] : "",
|
|
1886
|
+
const r = typeof n[0] == "string" ? n[0] : "", a = n[1], u = !!n[2], d = !!n[4], f = T(a);
|
|
1860
1887
|
if (r === "empty" && !f) {
|
|
1861
1888
|
this.setMessage(null);
|
|
1862
1889
|
continue;
|
|
1863
1890
|
}
|
|
1864
1891
|
if (!f) continue;
|
|
1865
|
-
if (
|
|
1892
|
+
if (d && this.messageEl?.textContent) {
|
|
1866
1893
|
this.setMessage(`${this.messageEl.textContent}${f}`);
|
|
1867
1894
|
continue;
|
|
1868
1895
|
}
|
|
1869
|
-
if (
|
|
1896
|
+
if (u) {
|
|
1870
1897
|
this.setMessage(f);
|
|
1871
1898
|
continue;
|
|
1872
1899
|
}
|
|
@@ -1874,8 +1901,8 @@ ${u}`), i < n && s.length > 0 && (u += `
|
|
|
1874
1901
|
continue;
|
|
1875
1902
|
}
|
|
1876
1903
|
if (i === "msg_showmode" || i === "msg_showcmd" || i === "msg_ruler") {
|
|
1877
|
-
const r = n[0],
|
|
1878
|
-
this.setMessage(
|
|
1904
|
+
const r = n[0], a = T(r);
|
|
1905
|
+
this.setMessage(a || null);
|
|
1879
1906
|
continue;
|
|
1880
1907
|
}
|
|
1881
1908
|
if (i === "popupmenu_hide") {
|
|
@@ -1883,8 +1910,8 @@ ${u}`), i < n && s.length > 0 && (u += `
|
|
|
1883
1910
|
continue;
|
|
1884
1911
|
}
|
|
1885
1912
|
if (i === "popupmenu_show") {
|
|
1886
|
-
const r = n[0],
|
|
1887
|
-
this.setPopupmenu(
|
|
1913
|
+
const r = n[0], a = Number(n[1] ?? -1), u = be(r);
|
|
1914
|
+
this.setPopupmenu(u, Number.isFinite(a) ? a : -1);
|
|
1888
1915
|
continue;
|
|
1889
1916
|
}
|
|
1890
1917
|
if (i === "popupmenu_select") {
|
|
@@ -1902,59 +1929,61 @@ ${u}`), i < n && s.length > 0 && (u += `
|
|
|
1902
1929
|
initTextInputListeners() {
|
|
1903
1930
|
const t = this.editor.getDomNode();
|
|
1904
1931
|
if (!t) return;
|
|
1905
|
-
const e = (
|
|
1932
|
+
const e = (l) => {
|
|
1906
1933
|
try {
|
|
1907
|
-
|
|
1934
|
+
l.stopImmediatePropagation?.();
|
|
1908
1935
|
} catch {
|
|
1909
1936
|
}
|
|
1910
1937
|
try {
|
|
1911
|
-
|
|
1938
|
+
l.stopPropagation();
|
|
1912
1939
|
} catch {
|
|
1913
1940
|
}
|
|
1914
|
-
}, i = (
|
|
1941
|
+
}, i = (l) => {
|
|
1915
1942
|
try {
|
|
1916
|
-
const
|
|
1917
|
-
|
|
1943
|
+
const c = l;
|
|
1944
|
+
if (!c || typeof c.tagName != "string") return null;
|
|
1945
|
+
const h = c.tagName;
|
|
1946
|
+
return h === "TEXTAREA" ? c.classList?.contains?.("inputarea") || c.classList?.contains?.("ime-text-area") ? c : null : h === "DIV" && c.classList?.contains?.("native-edit-context") ? c : null;
|
|
1918
1947
|
} catch {
|
|
1919
1948
|
return null;
|
|
1920
1949
|
}
|
|
1921
|
-
}, s = (
|
|
1922
|
-
if (this.compositionActive ||
|
|
1923
|
-
const
|
|
1924
|
-
if (!
|
|
1925
|
-
if (!this.opts.shouldHandleKey(
|
|
1926
|
-
const p = this.opts.translateKey(
|
|
1950
|
+
}, s = (l) => {
|
|
1951
|
+
if (this.compositionActive || l.isComposing || l.getModifierState?.("AltGraph")) return;
|
|
1952
|
+
const c = this.delegateInsertToMonaco && !this.exitingInsertMode;
|
|
1953
|
+
if (!c && (l.key === "Backspace" || l.key === "Delete" || l.key === "Escape")) {
|
|
1954
|
+
if (!this.opts.shouldHandleKey(l)) return;
|
|
1955
|
+
const p = this.opts.translateKey(l);
|
|
1927
1956
|
if (!p) return;
|
|
1928
|
-
e(
|
|
1957
|
+
e(l);
|
|
1929
1958
|
try {
|
|
1930
|
-
|
|
1959
|
+
l.preventDefault();
|
|
1931
1960
|
} catch {
|
|
1932
1961
|
}
|
|
1933
1962
|
this.exitingInsertMode ? this.pendingKeysAfterExit += p : this.sendInput(p);
|
|
1934
1963
|
return;
|
|
1935
1964
|
}
|
|
1936
|
-
if (
|
|
1937
|
-
const p = /^[\x20-\x7E]$/.test(
|
|
1938
|
-
if (!!!(
|
|
1939
|
-
if (!this.opts.shouldHandleKey(
|
|
1940
|
-
e(
|
|
1965
|
+
if (v(this.lastMode) && !this.delegateInsertToMonaco && !this.exitingInsertMode && !l.ctrlKey && !l.metaKey && typeof l.key == "string" && l.key.length === 1) {
|
|
1966
|
+
const p = /^[\x20-\x7E]$/.test(l.key);
|
|
1967
|
+
if (!!!(l.altKey && p)) {
|
|
1968
|
+
if (!this.opts.shouldHandleKey(l)) return;
|
|
1969
|
+
e(l);
|
|
1941
1970
|
return;
|
|
1942
1971
|
}
|
|
1943
1972
|
}
|
|
1944
|
-
if (!
|
|
1945
|
-
const
|
|
1946
|
-
if (!
|
|
1947
|
-
if (this.hasExplicitModAllowlist(
|
|
1948
|
-
if (!this.shouldForwardModifiedKeys(
|
|
1949
|
-
} else if (
|
|
1950
|
-
const m = this.opts.translateKey(
|
|
1973
|
+
if (!l.ctrlKey && !l.altKey && !l.metaKey) return;
|
|
1974
|
+
const h = this.modifiedKeyName(l);
|
|
1975
|
+
if (!h || !this.opts.shouldHandleKey(l)) return;
|
|
1976
|
+
if (this.hasExplicitModAllowlist(c)) {
|
|
1977
|
+
if (!this.shouldForwardModifiedKeys(l, c)) return;
|
|
1978
|
+
} else if (c || !l.ctrlKey || l.altKey || l.metaKey || h !== "f" && h !== "b" && h !== "d" && h !== "u" && h !== "e" && h !== "y" && h !== "v") return;
|
|
1979
|
+
const m = this.opts.translateKey(l);
|
|
1951
1980
|
if (m) {
|
|
1952
|
-
e(
|
|
1981
|
+
e(l);
|
|
1953
1982
|
try {
|
|
1954
|
-
|
|
1983
|
+
l.preventDefault();
|
|
1955
1984
|
} catch {
|
|
1956
1985
|
}
|
|
1957
|
-
this.exitingInsertMode ? (this.debugLog(`keydown(capture) buffer: key=${JSON.stringify(
|
|
1986
|
+
this.exitingInsertMode ? (this.debugLog(`keydown(capture) buffer: key=${JSON.stringify(l.key)} code=${JSON.stringify(l.code)} mods=${l.ctrlKey ? "C" : ""}${l.altKey ? "A" : ""}${l.metaKey ? "D" : ""}${l.shiftKey ? "S" : ""} -> ${m}`), this.pendingKeysAfterExit += m) : (c && this.flushPendingMonacoSync(), this.debugLog(`keydown(capture) send: key=${JSON.stringify(l.key)} code=${JSON.stringify(l.code)} mods=${l.ctrlKey ? "C" : ""}${l.altKey ? "A" : ""}${l.metaKey ? "D" : ""}${l.shiftKey ? "S" : ""} -> ${m}`), this.sendInput(m));
|
|
1958
1987
|
}
|
|
1959
1988
|
}, n = () => {
|
|
1960
1989
|
if (this.compositionActive = !0, this.debugLog(`compositionstart delegateInsert=${this.delegateInsertToMonaco} mode=${JSON.stringify(this.lastMode)}`), this.delegateInsertToMonaco) {
|
|
@@ -1962,70 +1991,80 @@ ${u}`), i < n && s.length > 0 && (u += `
|
|
|
1962
1991
|
return;
|
|
1963
1992
|
}
|
|
1964
1993
|
this.setPreedit("");
|
|
1965
|
-
}, r = (
|
|
1966
|
-
if (this.compositionActive = !1, this.setPreedit(null), this.debugLog(`compositionend delegateInsert=${this.delegateInsertToMonaco} mode=${JSON.stringify(this.lastMode)} data=${JSON.stringify(
|
|
1994
|
+
}, r = (l) => {
|
|
1995
|
+
if (this.compositionActive = !1, this.setPreedit(null), this.debugLog(`compositionend delegateInsert=${this.delegateInsertToMonaco} mode=${JSON.stringify(this.lastMode)} data=${JSON.stringify(l.data ?? "")}`), this.delegateInsertToMonaco) {
|
|
1967
1996
|
this.scheduleCursorSyncToNvim();
|
|
1968
1997
|
return;
|
|
1969
1998
|
}
|
|
1970
|
-
const
|
|
1971
|
-
if (
|
|
1972
|
-
const
|
|
1999
|
+
const c = i(l.target);
|
|
2000
|
+
if (v(this.lastMode)) {
|
|
2001
|
+
const h = typeof l.data == "string" ? l.data : "", m = !h && c && c.tagName === "TEXTAREA" && c.value ? String(c.value) : !h && c?.textContent ? String(c.textContent) : "", p = h || m;
|
|
1973
2002
|
p && this.sendCmdlineImeText(p);
|
|
1974
2003
|
}
|
|
1975
2004
|
try {
|
|
1976
|
-
|
|
1977
|
-
d && (d.value = "");
|
|
2005
|
+
c && c.tagName === "TEXTAREA" ? c.value = "" : c && (c.textContent = "");
|
|
1978
2006
|
} catch {
|
|
1979
2007
|
}
|
|
1980
2008
|
this.pendingResyncAfterComposition && (this.pendingResyncAfterComposition = !1, this.scheduleResync());
|
|
1981
|
-
},
|
|
2009
|
+
}, a = (l) => {
|
|
1982
2010
|
if (this.compositionActive || (this.compositionActive = !0), this.delegateInsertToMonaco) return;
|
|
1983
|
-
const
|
|
1984
|
-
this.setPreedit(
|
|
1985
|
-
},
|
|
1986
|
-
i(
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
2011
|
+
const c = i(l.target), h = typeof l.data == "string" ? l.data : c && c.tagName === "TEXTAREA" && c.value ? String(c.value) : c?.textContent ? String(c.textContent) : "";
|
|
2012
|
+
this.setPreedit(h || "");
|
|
2013
|
+
}, u = (l) => {
|
|
2014
|
+
if (i(l.target) && !(this.delegateInsertToMonaco && !this.exitingInsertMode)) {
|
|
2015
|
+
e(l);
|
|
2016
|
+
try {
|
|
2017
|
+
l.preventDefault?.();
|
|
2018
|
+
} catch {
|
|
2019
|
+
}
|
|
2020
|
+
if (v(this.lastMode) && !this.compositionActive) {
|
|
2021
|
+
const h = l, m = typeof h.data == "string" ? h.data : "", p = typeof h.inputType == "string" ? String(h.inputType) : "";
|
|
2022
|
+
!!!h.isComposing && !p.includes("Composition") && m && this.sendCmdlineImeText(m);
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
}, d = (l) => {
|
|
2026
|
+
const c = i(l.target);
|
|
2027
|
+
if (!c || this.delegateInsertToMonaco && !this.exitingInsertMode) return;
|
|
2028
|
+
e(l);
|
|
2029
|
+
const h = l;
|
|
1992
2030
|
if (this.ignoreNextInputEvent) {
|
|
1993
2031
|
this.ignoreNextInputEvent = !1;
|
|
1994
2032
|
try {
|
|
1995
|
-
|
|
2033
|
+
c.tagName === "TEXTAREA" ? c.value = "" : c.textContent = "";
|
|
1996
2034
|
} catch {
|
|
1997
2035
|
}
|
|
1998
2036
|
return;
|
|
1999
2037
|
}
|
|
2000
2038
|
if (!this.compositionActive) {
|
|
2001
|
-
if (
|
|
2002
|
-
const m = typeof
|
|
2039
|
+
if (v(this.lastMode)) {
|
|
2040
|
+
const m = typeof h.data == "string" ? h.data : "", p = !m && c.tagName === "TEXTAREA" && c.value ? String(c.value) : !m && c?.textContent ? String(c.textContent) : "", y = m || p;
|
|
2003
2041
|
y && this.sendCmdlineImeText(y);
|
|
2004
2042
|
}
|
|
2005
2043
|
try {
|
|
2006
|
-
|
|
2044
|
+
c.tagName === "TEXTAREA" ? c.value = "" : c.textContent = "";
|
|
2007
2045
|
} catch {
|
|
2008
2046
|
}
|
|
2009
2047
|
}
|
|
2010
|
-
}, f = (
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2048
|
+
}, f = (l) => {
|
|
2049
|
+
const c = i(l.target);
|
|
2050
|
+
if (!c || this.delegateInsertToMonaco && !this.exitingInsertMode) return;
|
|
2051
|
+
e(l);
|
|
2052
|
+
const h = l.clipboardData?.getData("text/plain") ?? "";
|
|
2053
|
+
h && (l.preventDefault(), this.ignoreNextInputEvent = !0, this.pasteText(h));
|
|
2015
2054
|
try {
|
|
2016
|
-
|
|
2055
|
+
c.tagName === "TEXTAREA" ? c.value = "" : c.textContent = "";
|
|
2017
2056
|
} catch {
|
|
2018
2057
|
}
|
|
2019
2058
|
};
|
|
2020
2059
|
this.disposables.push(
|
|
2021
2060
|
// Capture phase to ensure we see events even if Monaco stops propagation.
|
|
2022
|
-
|
|
2023
|
-
|
|
2024
|
-
|
|
2025
|
-
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2061
|
+
C(t, "keydown", s, !0),
|
|
2062
|
+
C(t, "beforeinput", u, !0),
|
|
2063
|
+
C(t, "input", d, !0),
|
|
2064
|
+
C(t, "paste", f, !0),
|
|
2065
|
+
C(t, "compositionstart", n, !0),
|
|
2066
|
+
C(t, "compositionupdate", a, !0),
|
|
2067
|
+
C(t, "compositionend", r, !0)
|
|
2029
2068
|
);
|
|
2030
2069
|
}
|
|
2031
2070
|
scheduleResync() {
|
|
@@ -2132,7 +2171,7 @@ ${u}`), i < n && s.length > 0 && (u += `
|
|
|
2132
2171
|
} catch {
|
|
2133
2172
|
}
|
|
2134
2173
|
e = Math.max(1, Math.min(e, t.getLineCount())), i = Math.max(1, Math.min(i, t.getLineCount()));
|
|
2135
|
-
const s = await this.execLua(
|
|
2174
|
+
const s = await this.execLua(ae, [e, i]);
|
|
2136
2175
|
this.applySearchHighlights(s, t);
|
|
2137
2176
|
} catch {
|
|
2138
2177
|
}
|
|
@@ -2149,27 +2188,27 @@ ${u}`), i < n && s.length > 0 && (u += `
|
|
|
2149
2188
|
this.clearSearchHighlights();
|
|
2150
2189
|
return;
|
|
2151
2190
|
}
|
|
2152
|
-
const n = Array.isArray(i.matches) ? i.matches : [], r = i.current && typeof i.current == "object" ? i.current : null,
|
|
2153
|
-
if (f.has(
|
|
2154
|
-
const
|
|
2155
|
-
return f.set(
|
|
2191
|
+
const n = Array.isArray(i.matches) ? i.matches : [], r = i.current && typeof i.current == "object" ? i.current : null, a = r && Number.isFinite(Number(r.l)) ? `${Number(r.l)}:${Number(r.s)}:${Number(r.e)}` : null, u = [], d = 2e3, f = /* @__PURE__ */ new Map(), l = (c) => {
|
|
2192
|
+
if (f.has(c)) return f.get(c);
|
|
2193
|
+
const h = e.getLineContent(c) ?? "";
|
|
2194
|
+
return f.set(c, h), h;
|
|
2156
2195
|
};
|
|
2157
|
-
for (let
|
|
2158
|
-
const
|
|
2196
|
+
for (let c = 0; c < n.length && u.length < d; c += 1) {
|
|
2197
|
+
const h = n[c], m = Number(h?.l), p = Number(h?.s), y = Number(h?.e);
|
|
2159
2198
|
if (!Number.isFinite(m) || !Number.isFinite(p) || !Number.isFinite(y)) continue;
|
|
2160
2199
|
const b = m + 1;
|
|
2161
2200
|
if (b < 1 || b > e.getLineCount()) continue;
|
|
2162
|
-
const
|
|
2163
|
-
if (D <=
|
|
2164
|
-
const W = `${m}:${p}:${y}`, z =
|
|
2165
|
-
|
|
2166
|
-
range: new g.Range(b,
|
|
2201
|
+
const I = l(b), P = S(I, Math.max(0, p)) + 1, D = S(I, Math.max(0, y)) + 1;
|
|
2202
|
+
if (D <= P) continue;
|
|
2203
|
+
const W = `${m}:${p}:${y}`, z = a && W === a ? "monaco-neovim-search-current" : "monaco-neovim-search-match";
|
|
2204
|
+
u.push({
|
|
2205
|
+
range: new g.Range(b, P, b, D),
|
|
2167
2206
|
options: { inlineClassName: z }
|
|
2168
2207
|
});
|
|
2169
2208
|
}
|
|
2170
2209
|
this.ensureSearchStyle();
|
|
2171
2210
|
try {
|
|
2172
|
-
this.searchDecorationIds = this.editor.deltaDecorations(this.searchDecorationIds,
|
|
2211
|
+
this.searchDecorationIds = this.editor.deltaDecorations(this.searchDecorationIds, u);
|
|
2173
2212
|
} catch {
|
|
2174
2213
|
this.searchDecorationIds = [];
|
|
2175
2214
|
}
|
|
@@ -2178,20 +2217,20 @@ ${u}`), i < n && s.length > 0 && (u += `
|
|
|
2178
2217
|
this.ensureVisualStyle();
|
|
2179
2218
|
const s = ge(e) === "V", n = [];
|
|
2180
2219
|
if (s) {
|
|
2181
|
-
let r = 1 / 0,
|
|
2182
|
-
for (const
|
|
2183
|
-
const
|
|
2184
|
-
r = Math.min(r,
|
|
2220
|
+
let r = 1 / 0, a = -1 / 0;
|
|
2221
|
+
for (const u of t) {
|
|
2222
|
+
const d = u.getStartPosition(), f = u.getEndPosition();
|
|
2223
|
+
r = Math.min(r, d.lineNumber, f.lineNumber), a = Math.max(a, d.lineNumber, f.lineNumber);
|
|
2185
2224
|
}
|
|
2186
|
-
Number.isFinite(r) && Number.isFinite(
|
|
2187
|
-
range: new g.Range(r, 1,
|
|
2225
|
+
Number.isFinite(r) && Number.isFinite(a) && a >= r && n.push({
|
|
2226
|
+
range: new g.Range(r, 1, a, 1),
|
|
2188
2227
|
options: { isWholeLine: !0, className: "monaco-neovim-visual-line" }
|
|
2189
2228
|
});
|
|
2190
2229
|
} else
|
|
2191
2230
|
for (const r of t) {
|
|
2192
|
-
const
|
|
2231
|
+
const a = r.getStartPosition(), u = r.getEndPosition();
|
|
2193
2232
|
n.push({
|
|
2194
|
-
range: g.Range.fromPositions(
|
|
2233
|
+
range: g.Range.fromPositions(a, u),
|
|
2195
2234
|
options: { inlineClassName: "monaco-neovim-visual-inline" }
|
|
2196
2235
|
});
|
|
2197
2236
|
}
|
|
@@ -2205,7 +2244,7 @@ ${u}`), i < n && s.length > 0 && (u += `
|
|
|
2205
2244
|
const e = typeof t == "string" ? t : "";
|
|
2206
2245
|
if (!e || e === this.lastMode) return;
|
|
2207
2246
|
const i = this.lastMode;
|
|
2208
|
-
this.lastMode = e,
|
|
2247
|
+
this.lastMode = e, v(e) && (this.ignoreNextInputEvent = !1);
|
|
2209
2248
|
const s = $(e) && !this.recordingRegister;
|
|
2210
2249
|
if (s !== this.delegateInsertToMonaco) {
|
|
2211
2250
|
this.delegateInsertToMonaco = s;
|
|
@@ -2217,7 +2256,7 @@ ${u}`), i < n && s.length > 0 && (u += `
|
|
|
2217
2256
|
const n = this.pendingKeysAfterExit;
|
|
2218
2257
|
this.pendingKeysAfterExit = "", n && this.sendInput(n);
|
|
2219
2258
|
}
|
|
2220
|
-
if (this.applyCursorStyle(e), this.opts.onModeChange && this.opts.onModeChange(e), this.updateVisualSelection(e),
|
|
2259
|
+
if (this.applyCursorStyle(e), this.opts.onModeChange && this.opts.onModeChange(e), this.updateVisualSelection(e), w(i) && !w(e))
|
|
2221
2260
|
try {
|
|
2222
2261
|
const n = this.editor.getPosition() ?? this.lastCursorPos;
|
|
2223
2262
|
n && !this.compositionActive && (this.suppressCursorSync = !0, this.editor.setSelection(new g.Selection(n.lineNumber, n.column, n.lineNumber, n.column)), this.suppressCursorSync = !1);
|
|
@@ -2270,7 +2309,6 @@ vim.opt.ei = ei
|
|
|
2270
2309
|
}
|
|
2271
2310
|
handleKey(t) {
|
|
2272
2311
|
const e = t.browserEvent;
|
|
2273
|
-
if (e.defaultPrevented && e.key !== "Escape" && e.key !== "Enter") return;
|
|
2274
2312
|
if (this.exitingInsertMode) {
|
|
2275
2313
|
if (e.key === "Escape") {
|
|
2276
2314
|
t.preventDefault();
|
|
@@ -2302,7 +2340,7 @@ vim.opt.ei = ei
|
|
|
2302
2340
|
}
|
|
2303
2341
|
return;
|
|
2304
2342
|
}
|
|
2305
|
-
if (
|
|
2343
|
+
if (v(this.lastMode) && !this.compositionActive && !e.isComposing && !e.getModifierState?.("AltGraph") && !e.ctrlKey && !e.metaKey && typeof e.key == "string" && e.key.length === 1) {
|
|
2306
2344
|
const s = /^[\x20-\x7E]$/.test(e.key);
|
|
2307
2345
|
if (!!!(e.altKey && s))
|
|
2308
2346
|
return this.opts.shouldHandleKey(e), void 0;
|
|
@@ -2320,15 +2358,15 @@ vim.opt.ei = ei
|
|
|
2320
2358
|
}
|
|
2321
2359
|
handleMouse(t) {
|
|
2322
2360
|
if (this.delegateInsertToMonaco || !this.bufHandle || !t.target?.position) return;
|
|
2323
|
-
const { lineNumber: e, column: i } = t.target.position, s = this.editor.getModel(), n = Math.max(0, i - 1), r = s ? s.getLineContent(e) ?? "" : "",
|
|
2324
|
-
this.sendNotify("nvim_win_set_cursor", [0, [e,
|
|
2361
|
+
const { lineNumber: e, column: i } = t.target.position, s = this.editor.getModel(), n = Math.max(0, i - 1), r = s ? s.getLineContent(e) ?? "" : "", a = s ? _(r, n) : n;
|
|
2362
|
+
this.sendNotify("nvim_win_set_cursor", [0, [e, a]]);
|
|
2325
2363
|
}
|
|
2326
2364
|
handleSelection(t) {
|
|
2327
2365
|
if (this.delegateInsertToMonaco || !this.session || !this.session.isRunning() || !this.bufHandle || this.suppressCursorSync || this.compositionActive || t?.isComposing) return;
|
|
2328
2366
|
const e = t.selection;
|
|
2329
2367
|
if (e && t.source === "mouse") {
|
|
2330
2368
|
if (e.isEmpty()) {
|
|
2331
|
-
|
|
2369
|
+
w(this.lastMode) && this.sendInput("<Esc>");
|
|
2332
2370
|
return;
|
|
2333
2371
|
}
|
|
2334
2372
|
this.pendingSelection = new g.Selection(
|
|
@@ -2348,7 +2386,7 @@ vim.opt.ei = ei
|
|
|
2348
2386
|
if (this.delegateInsertToMonaco || !this.session || !this.session.isRunning() || !this.bufHandle) return;
|
|
2349
2387
|
const e = this.editor.getModel();
|
|
2350
2388
|
if (!e) return;
|
|
2351
|
-
const i = t.selectionStartLineNumber, s = Math.max(0, t.selectionStartColumn - 1), n = t.positionLineNumber, r = Math.max(0, t.positionColumn - 1),
|
|
2389
|
+
const i = t.selectionStartLineNumber, s = Math.max(0, t.selectionStartColumn - 1), n = t.positionLineNumber, r = Math.max(0, t.positionColumn - 1), a = e.getLineContent(i) ?? "", u = e.getLineContent(n) ?? "", d = _(a, s), f = _(u, r);
|
|
2352
2390
|
await this.execLua(`
|
|
2353
2391
|
local api = vim.api
|
|
2354
2392
|
local fn = vim.fn
|
|
@@ -2361,7 +2399,7 @@ end
|
|
|
2361
2399
|
api.nvim_win_set_cursor(0, { a_line, a_col0 })
|
|
2362
2400
|
api.nvim_feedkeys("v", "n", false)
|
|
2363
2401
|
api.nvim_win_set_cursor(0, { b_line, b_col0 })
|
|
2364
|
-
`, [i,
|
|
2402
|
+
`, [i, d, n, f]);
|
|
2365
2403
|
}
|
|
2366
2404
|
sendInput(t) {
|
|
2367
2405
|
this.sendNotify("nvim_input", [t]);
|
|
@@ -2434,22 +2472,20 @@ api.nvim_win_set_cursor(0, { b_line, b_col0 })
|
|
|
2434
2472
|
i.pendingFullSync = !0, i.pendingCursorSync = !0, i.shadowLines = e.getLinesContent(), this.scheduleFlushPendingMonacoSync();
|
|
2435
2473
|
return;
|
|
2436
2474
|
}
|
|
2437
|
-
const s = t.changes[0], n = s.range, r = n.startLineNumber - 1,
|
|
2438
|
-
if (r < 0 ||
|
|
2439
|
-
if (i.shadowLines[r] == null || i.shadowLines[
|
|
2475
|
+
const s = t.changes[0], n = s.range, r = n.startLineNumber - 1, a = n.endLineNumber - 1;
|
|
2476
|
+
if (r < 0 || a < 0) return;
|
|
2477
|
+
if (i.shadowLines[r] == null || i.shadowLines[a] == null) {
|
|
2440
2478
|
i.pendingFullSync = !0, i.pendingCursorSync = !0, i.shadowLines = e.getLinesContent(), this.scheduleFlushPendingMonacoSync();
|
|
2441
2479
|
return;
|
|
2442
2480
|
}
|
|
2443
|
-
const
|
|
2481
|
+
const u = i.shadowLines[r] ?? "", d = i.shadowLines[a] ?? "", f = Math.max(0, n.startColumn - 1), l = Math.max(0, n.endColumn - 1), c = _(u, f), h = _(d, l), m = String(s.text ?? ""), p = m.length ? m.split(/\r?\n/) : [];
|
|
2444
2482
|
try {
|
|
2445
|
-
const
|
|
2446
|
-
r ===
|
|
2447
|
-
`) ? (
|
|
2483
|
+
const y = Math.max(0, Number(s.rangeLength ?? 0) || 0);
|
|
2484
|
+
r === a && !m.includes(`
|
|
2485
|
+
`) ? (y > 0 && (this.dotRepeatBackspaces += y, this.dotRepeatKeys += "<BS>".repeat(y)), m && (this.dotRepeatKeys += k(m, !0)), this.dotRepeatKeys.length > 2e4 && (this.dotRepeatKeys = "", this.dotRepeatBackspaces = 0)) : (this.dotRepeatKeys = "", this.dotRepeatBackspaces = 0);
|
|
2448
2486
|
} catch {
|
|
2449
2487
|
}
|
|
2450
|
-
i.pendingBufEdits.push({ startRow: r, startColByte:
|
|
2451
|
-
const y = typeof performance < "u" && performance.now ? performance.now() : Date.now();
|
|
2452
|
-
this.ignoreNvimBufLinesUntil = y + Math.max(80, (this.opts.insertSyncDebounceMs || 20) * 4), this.scheduleFlushPendingMonacoSync();
|
|
2488
|
+
i.pendingBufEdits.push({ startRow: r, startColByte: c, endRow: a, endColByte: h, lines: p }), ye(i.shadowLines, r, f, a, l, m), i.pendingCursorSync = !0, this.scheduleFlushPendingMonacoSync();
|
|
2453
2489
|
}
|
|
2454
2490
|
scheduleCursorSyncToNvim() {
|
|
2455
2491
|
if (!this.delegateInsertToMonaco) return;
|
|
@@ -2484,7 +2520,7 @@ api.nvim_win_set_cursor(0, { b_line, b_col0 })
|
|
|
2484
2520
|
if (!this.session || !this.session.isRunning() || !this.bufHandle) return;
|
|
2485
2521
|
const t = this.editor.getModel(), e = this.editor.getPosition();
|
|
2486
2522
|
if (!t || !e) return;
|
|
2487
|
-
const i = e.lineNumber, s = t.getLineContent(i) ?? "", n =
|
|
2523
|
+
const i = e.lineNumber, s = t.getLineContent(i) ?? "", n = _(s, Math.max(0, e.column - 1));
|
|
2488
2524
|
this.sendNotify("nvim_win_set_cursor", [0, [i, n]]);
|
|
2489
2525
|
}
|
|
2490
2526
|
scheduleVisualSelectionRefresh() {
|
|
@@ -2498,7 +2534,7 @@ api.nvim_win_set_cursor(0, { b_line, b_col0 })
|
|
|
2498
2534
|
const t = await this.rpcCall("nvim_get_api_info", []), e = Array.isArray(t) ? Number(t[0]) : NaN;
|
|
2499
2535
|
if (!Number.isFinite(e) || e <= 0) return;
|
|
2500
2536
|
this.nvimChannelId = e;
|
|
2501
|
-
const i = this.opts.wrappedLineMotions ? "true" : "false", s = this.opts.scrollMotions ? "true" : "false", n = this.opts.syncScrolloff && this.opts.scrolloff == null ? "true" : "false", r = this.opts.hostCommands ? "true" : "false",
|
|
2537
|
+
const i = this.opts.wrappedLineMotions ? "true" : "false", s = this.opts.scrollMotions ? "true" : "false", n = this.opts.syncScrolloff && this.opts.scrolloff == null ? "true" : "false", r = this.opts.hostCommands ? "true" : "false", a = `
|
|
2502
2538
|
local chan = ...
|
|
2503
2539
|
local api = vim.api
|
|
2504
2540
|
vim.g.monaco_neovim_wasm_chan = chan
|
|
@@ -2586,7 +2622,7 @@ vim.rpcnotify(chan, "monaco_buf_enter", {
|
|
|
2586
2622
|
filetype = (vim.bo[api.nvim_get_current_buf()] and vim.bo[api.nvim_get_current_buf()].filetype) or "",
|
|
2587
2623
|
})
|
|
2588
2624
|
`;
|
|
2589
|
-
await this.execLua(
|
|
2625
|
+
await this.execLua(a, [e]), this.hostAutocmdInstalled = !0;
|
|
2590
2626
|
} catch {
|
|
2591
2627
|
}
|
|
2592
2628
|
}
|
|
@@ -2619,8 +2655,8 @@ vim.rpcnotify(chan, "monaco_buf_enter", {
|
|
|
2619
2655
|
try {
|
|
2620
2656
|
const r = await s.readFile(n);
|
|
2621
2657
|
if (r == null) return;
|
|
2622
|
-
const
|
|
2623
|
-
await this.openText({ path: n, text:
|
|
2658
|
+
const a = r instanceof Uint8Array ? new TextDecoder().decode(r) : String(r);
|
|
2659
|
+
await this.openText({ path: n, text: a }), this.opts.status(`opened: ${n}`);
|
|
2624
2660
|
} catch (r) {
|
|
2625
2661
|
this.opts.status(`edit failed: ${r?.message ?? r}`, !0);
|
|
2626
2662
|
}
|
|
@@ -2628,31 +2664,31 @@ vim.rpcnotify(chan, "monaco_buf_enter", {
|
|
|
2628
2664
|
}
|
|
2629
2665
|
if (e === "write" || e === "wq") {
|
|
2630
2666
|
const n = this.editor.getModel(), r = n ? n.getValue() : "";
|
|
2631
|
-
let
|
|
2632
|
-
if (!
|
|
2667
|
+
let a = typeof i.path == "string" ? String(i.path) : "";
|
|
2668
|
+
if (!a)
|
|
2633
2669
|
try {
|
|
2634
|
-
const
|
|
2635
|
-
typeof
|
|
2670
|
+
const u = await this.rpcCall("nvim_buf_get_name", [0]);
|
|
2671
|
+
typeof u == "string" && (a = u);
|
|
2636
2672
|
} catch {
|
|
2637
2673
|
}
|
|
2638
|
-
if (
|
|
2674
|
+
if (a || (a = this.opts.seedName), !s.writeFile) {
|
|
2639
2675
|
this.opts.status("write: fileSystem.writeFile not set", !0);
|
|
2640
2676
|
return;
|
|
2641
2677
|
}
|
|
2642
2678
|
try {
|
|
2643
|
-
await s.writeFile(
|
|
2679
|
+
await s.writeFile(a, r);
|
|
2644
2680
|
try {
|
|
2645
|
-
await this.rpcCall("nvim_buf_set_name", [0,
|
|
2681
|
+
await this.rpcCall("nvim_buf_set_name", [0, a]);
|
|
2646
2682
|
} catch {
|
|
2647
2683
|
}
|
|
2648
2684
|
try {
|
|
2649
2685
|
await this.rpcCall("nvim_buf_set_option", [0, "modified", !1]);
|
|
2650
2686
|
} catch {
|
|
2651
2687
|
}
|
|
2652
|
-
const
|
|
2653
|
-
|
|
2654
|
-
} catch (
|
|
2655
|
-
this.opts.status(`write failed: ${
|
|
2688
|
+
const u = this.getActiveState();
|
|
2689
|
+
u && (u.name && u.name !== a && this.buffersByName.delete(u.name), u.name = a, this.buffersByName.set(a, u.id)), this.opts.status(`written: ${a}`), e === "wq" && this.opts.status("wq requested (provide onHostCommand to close the editor)");
|
|
2690
|
+
} catch (u) {
|
|
2691
|
+
this.opts.status(`write failed: ${u?.message ?? u}`, !0);
|
|
2656
2692
|
}
|
|
2657
2693
|
return;
|
|
2658
2694
|
}
|
|
@@ -2673,19 +2709,19 @@ vim.rpcnotify(chan, "monaco_buf_enter", {
|
|
|
2673
2709
|
await this.rpcCall("nvim_buf_attach", [e, !1, {}]);
|
|
2674
2710
|
} catch {
|
|
2675
2711
|
}
|
|
2676
|
-
let
|
|
2712
|
+
let a = [""];
|
|
2677
2713
|
try {
|
|
2678
|
-
const
|
|
2679
|
-
Array.isArray(
|
|
2714
|
+
const c = await this.rpcCall("nvim_buf_get_lines", [e, 0, -1, !1]);
|
|
2715
|
+
Array.isArray(c) && (a = c.map((h) => String(h ?? "")));
|
|
2680
2716
|
} catch {
|
|
2681
2717
|
}
|
|
2682
|
-
const
|
|
2683
|
-
`), f = s && g.languages.getLanguages().some((
|
|
2718
|
+
const u = g.Uri.from({ scheme: "nvim", authority: "buf", path: `/${e}` }), d = a.join(`
|
|
2719
|
+
`), f = s && g.languages.getLanguages().some((c) => c.id === s), l = g.editor.createModel(d, f ? s : void 0, u);
|
|
2684
2720
|
n = {
|
|
2685
2721
|
id: e,
|
|
2686
2722
|
name: i || "",
|
|
2687
2723
|
filetype: s || "",
|
|
2688
|
-
model:
|
|
2724
|
+
model: l,
|
|
2689
2725
|
createdModel: !0,
|
|
2690
2726
|
shadowLines: null,
|
|
2691
2727
|
pendingBufEdits: [],
|
|
@@ -2787,8 +2823,8 @@ vim.rpcnotify(chan, "monaco_buf_enter", {
|
|
|
2787
2823
|
updateCursor(t, e) {
|
|
2788
2824
|
const i = this.editor.getModel(), s = Math.max(1, Number(t) || 1), n = Math.max(1, Number(e) || 1), r = i ? i.validatePosition(new g.Position(s, n)) : new g.Position(s, n);
|
|
2789
2825
|
if (this.lastCursorPos = r, this.compositionActive) return;
|
|
2790
|
-
const
|
|
2791
|
-
|
|
2826
|
+
const a = this.editor.getPosition();
|
|
2827
|
+
a && a.lineNumber === r.lineNumber && a.column === r.column || (this.suppressCursorSync = !0, this.editor.setPosition(this.lastCursorPos), this.visualSelectionActive && this.editor.setSelection(new g.Selection(r.lineNumber, r.column, r.lineNumber, r.column)), this.applyScrolloff(this.lastCursorPos) || this.editor.revealPositionInCenterIfOutsideViewport(this.lastCursorPos), this.suppressCursorSync = !1), this.scheduleSearchHighlightRefresh();
|
|
2792
2828
|
}
|
|
2793
2829
|
scheduleCursorRefresh() {
|
|
2794
2830
|
if (this.compositionActive || this.cursorRefreshTimer) return;
|
|
@@ -2812,10 +2848,10 @@ vim.rpcnotify(chan, "monaco_buf_enter", {
|
|
|
2812
2848
|
try {
|
|
2813
2849
|
const e = await this.rpcCall("nvim_win_get_cursor", [0]);
|
|
2814
2850
|
if (Array.isArray(e) && e.length >= 2) {
|
|
2815
|
-
const i = Number(e[0]), s = Number(e[1]), n = B(this.editor, i, s), r = new g.Position(n.line, n.col),
|
|
2816
|
-
if (this.optimisticCursorPos && this.optimisticCursorUntil >
|
|
2817
|
-
const
|
|
2818
|
-
|
|
2851
|
+
const i = Number(e[0]), s = Number(e[1]), n = B(this.editor, i, s), r = new g.Position(n.line, n.col), a = typeof performance < "u" && performance.now ? performance.now() : Date.now();
|
|
2852
|
+
if (this.optimisticCursorPos && this.optimisticCursorUntil > a) {
|
|
2853
|
+
const u = this.optimisticCursorPrevPos;
|
|
2854
|
+
u && r.lineNumber === u.lineNumber && r.column === u.column || r.lineNumber < this.optimisticCursorPos.lineNumber || r.lineNumber === this.optimisticCursorPos.lineNumber && r.column < this.optimisticCursorPos.column || (this.optimisticCursorPos = null, this.optimisticCursorPrevPos = null, this.optimisticCursorUntil = 0, this.updateCursor(r.lineNumber, r.column));
|
|
2819
2855
|
} else
|
|
2820
2856
|
this.optimisticCursorPos = null, this.optimisticCursorPrevPos = null, this.optimisticCursorUntil = 0, this.updateCursor(r.lineNumber, r.column);
|
|
2821
2857
|
}
|
|
@@ -2839,7 +2875,7 @@ vim.rpcnotify(chan, "monaco_buf_enter", {
|
|
|
2839
2875
|
s === this.lastCursorStyle && n === this.lastCursorBlink && r === this.lastCursorWidth || (this.editor.updateOptions({ cursorStyle: s, cursorBlinking: n, cursorWidth: r }), this.lastCursorStyle = s, this.lastCursorBlink = n, this.lastCursorWidth = r);
|
|
2840
2876
|
}
|
|
2841
2877
|
async updateVisualSelection(t) {
|
|
2842
|
-
const e =
|
|
2878
|
+
const e = w(t), i = ++this.visualSelectionToken;
|
|
2843
2879
|
if (!e) {
|
|
2844
2880
|
this.clearVisualDecorations();
|
|
2845
2881
|
return;
|
|
@@ -2895,13 +2931,13 @@ vim.rpcnotify(chan, "monaco_buf_enter", {
|
|
|
2895
2931
|
}
|
|
2896
2932
|
}
|
|
2897
2933
|
}
|
|
2898
|
-
function
|
|
2899
|
-
return new
|
|
2934
|
+
function Ce(o, t = {}) {
|
|
2935
|
+
return new le(o, t);
|
|
2900
2936
|
}
|
|
2901
|
-
function
|
|
2937
|
+
function M(o, t, e) {
|
|
2902
2938
|
return Math.min(Math.max(o, t), e);
|
|
2903
2939
|
}
|
|
2904
|
-
function
|
|
2940
|
+
function A(o) {
|
|
2905
2941
|
try {
|
|
2906
2942
|
return new TextEncoder().encode(String(o ?? "")).length;
|
|
2907
2943
|
} catch {
|
|
@@ -2912,10 +2948,10 @@ function B(o, t, e) {
|
|
|
2912
2948
|
const i = Math.max(1, Number(t) || 1), s = Math.max(1, (Number(e) || 0) + 1), n = o.getModel();
|
|
2913
2949
|
if (!n)
|
|
2914
2950
|
return { line: i, col: s };
|
|
2915
|
-
const r = n.getLineCount(),
|
|
2916
|
-
return { line:
|
|
2951
|
+
const r = n.getLineCount(), a = M(i, 1, r), u = n.getLineContent(a) ?? "", d = n.getLineMaxColumn(a), f = Math.max(0, Number(e) || 0), l = S(u, f), c = M(l + 1, 1, d);
|
|
2952
|
+
return { line: a, col: c };
|
|
2917
2953
|
}
|
|
2918
|
-
function
|
|
2954
|
+
function k(o, t = !0) {
|
|
2919
2955
|
const e = String(o ?? "");
|
|
2920
2956
|
if (!e) return "";
|
|
2921
2957
|
const i = e.replace(/\r\n/g, `
|
|
@@ -2926,65 +2962,65 @@ function L(o, t = !0) {
|
|
|
2926
2962
|
function ce(o) {
|
|
2927
2963
|
const t = o.key;
|
|
2928
2964
|
if (!t || t === "Dead" || t === "Unidentified") return null;
|
|
2929
|
-
const e = !!o.getModifierState?.("AltGraph"), i = o.ctrlKey && !e, s = o.altKey && !e, n = o.metaKey && !e, r = o.shiftKey,
|
|
2930
|
-
const
|
|
2931
|
-
i &&
|
|
2932
|
-
const m = l
|
|
2933
|
-
return
|
|
2965
|
+
const e = !!o.getModifierState?.("AltGraph"), i = o.ctrlKey && !e, s = o.altKey && !e, n = o.metaKey && !e, r = o.shiftKey, a = (l) => l === "<" ? "lt" : l, u = (l) => l === "<" ? "<lt>" : l, d = (l, c = !1) => {
|
|
2966
|
+
const h = [];
|
|
2967
|
+
i && h.push("C-"), c && r && h.push("S-"), s && h.push("A-"), n && h.push("D-");
|
|
2968
|
+
const m = a(l);
|
|
2969
|
+
return h.length ? `<${h.join("")}${m}>` : `<${m}>`;
|
|
2934
2970
|
};
|
|
2935
2971
|
if (typeof o.code == "string" && o.code.startsWith("Numpad") || typeof KeyboardEvent?.DOM_KEY_LOCATION_NUMPAD == "number" && o.location === KeyboardEvent.DOM_KEY_LOCATION_NUMPAD) {
|
|
2936
2972
|
switch (o.code) {
|
|
2937
2973
|
case "NumpadEnter":
|
|
2938
|
-
return
|
|
2974
|
+
return d("kEnter", !0);
|
|
2939
2975
|
case "NumpadAdd":
|
|
2940
|
-
return
|
|
2976
|
+
return d("kPlus", !0);
|
|
2941
2977
|
case "NumpadSubtract":
|
|
2942
|
-
return
|
|
2978
|
+
return d("kMinus", !0);
|
|
2943
2979
|
case "NumpadMultiply":
|
|
2944
|
-
return
|
|
2980
|
+
return d("kMultiply", !0);
|
|
2945
2981
|
case "NumpadDivide":
|
|
2946
|
-
return
|
|
2982
|
+
return d("kDivide", !0);
|
|
2947
2983
|
case "NumpadDecimal":
|
|
2948
|
-
return
|
|
2984
|
+
return d("kPoint", !0);
|
|
2949
2985
|
}
|
|
2950
|
-
if (/^\d$/.test(t)) return
|
|
2986
|
+
if (/^\d$/.test(t)) return d(`k${t}`, !0);
|
|
2951
2987
|
}
|
|
2952
2988
|
switch (t) {
|
|
2953
2989
|
case "Backspace":
|
|
2954
|
-
return
|
|
2990
|
+
return d("BS", !0);
|
|
2955
2991
|
case "Enter":
|
|
2956
|
-
return
|
|
2992
|
+
return d("CR", !0);
|
|
2957
2993
|
case "Escape":
|
|
2958
|
-
return
|
|
2994
|
+
return d("Esc", !0);
|
|
2959
2995
|
case "Tab":
|
|
2960
|
-
return r && !i && !s && !n ? "<S-Tab>" :
|
|
2996
|
+
return r && !i && !s && !n ? "<S-Tab>" : d("Tab", !0);
|
|
2961
2997
|
case "ArrowUp":
|
|
2962
|
-
return
|
|
2998
|
+
return d("Up", !0);
|
|
2963
2999
|
case "ArrowDown":
|
|
2964
|
-
return
|
|
3000
|
+
return d("Down", !0);
|
|
2965
3001
|
case "ArrowLeft":
|
|
2966
|
-
return
|
|
3002
|
+
return d("Left", !0);
|
|
2967
3003
|
case "ArrowRight":
|
|
2968
|
-
return
|
|
3004
|
+
return d("Right", !0);
|
|
2969
3005
|
case "Delete":
|
|
2970
|
-
return
|
|
3006
|
+
return d("Del", !0);
|
|
2971
3007
|
case "Home":
|
|
2972
|
-
return
|
|
3008
|
+
return d("Home", !0);
|
|
2973
3009
|
case "End":
|
|
2974
|
-
return
|
|
3010
|
+
return d("End", !0);
|
|
2975
3011
|
case "PageUp":
|
|
2976
|
-
return
|
|
3012
|
+
return d("PageUp", !0);
|
|
2977
3013
|
case "PageDown":
|
|
2978
|
-
return
|
|
3014
|
+
return d("PageDown", !0);
|
|
2979
3015
|
case "Insert":
|
|
2980
|
-
return
|
|
3016
|
+
return d("Insert", !0);
|
|
2981
3017
|
}
|
|
2982
|
-
if (/^F\d{1,2}$/.test(t)) return
|
|
3018
|
+
if (/^F\d{1,2}$/.test(t)) return d(t, !0);
|
|
2983
3019
|
if (t.length === 1) {
|
|
2984
|
-
if (!i && !s && !n) return
|
|
3020
|
+
if (!i && !s && !n) return u(t);
|
|
2985
3021
|
if (t === " " && i && !s && !n) return "<Nul>";
|
|
2986
|
-
const
|
|
2987
|
-
return `<${(i ? "C-" : "") + (s ? "A-" : "") + (n ? "D-" : "")}${
|
|
3022
|
+
const l = /^[A-Za-z]$/.test(t) ? t.toLowerCase() : t, c = a(l);
|
|
3023
|
+
return `<${(i ? "C-" : "") + (s ? "A-" : "") + (n ? "D-" : "")}${c}>`;
|
|
2988
3024
|
}
|
|
2989
3025
|
return null;
|
|
2990
3026
|
}
|
|
@@ -3029,27 +3065,27 @@ function x(o) {
|
|
|
3029
3065
|
const t = Number(o);
|
|
3030
3066
|
return Number.isInteger(t) && t > 0 ? t : null;
|
|
3031
3067
|
}
|
|
3032
|
-
function
|
|
3068
|
+
function S(o, t) {
|
|
3033
3069
|
let e = 0, i = 0;
|
|
3034
3070
|
const s = Math.max(0, Number(t) || 0);
|
|
3035
3071
|
for (; e < s; ) {
|
|
3036
3072
|
if (i >= o.length)
|
|
3037
3073
|
return i + (s - e);
|
|
3038
|
-
const n = o.codePointAt(i), r =
|
|
3074
|
+
const n = o.codePointAt(i), r = L(n ?? 0);
|
|
3039
3075
|
e += r, i += r === 4 ? 2 : 1;
|
|
3040
3076
|
}
|
|
3041
3077
|
return i;
|
|
3042
3078
|
}
|
|
3043
|
-
function
|
|
3079
|
+
function _(o, t) {
|
|
3044
3080
|
const e = Math.max(0, Number(t) || 0);
|
|
3045
3081
|
let i = 0, s = 0;
|
|
3046
3082
|
for (; s < e && s < o.length; ) {
|
|
3047
|
-
const n = o.codePointAt(s), r =
|
|
3083
|
+
const n = o.codePointAt(s), r = L(n ?? 0);
|
|
3048
3084
|
i += r, s += r === 4 ? 2 : 1;
|
|
3049
3085
|
}
|
|
3050
3086
|
return i;
|
|
3051
3087
|
}
|
|
3052
|
-
function
|
|
3088
|
+
function L(o) {
|
|
3053
3089
|
return o == null ? 0 : o <= 127 ? 1 : o <= 2047 ? 2 : o >= 55296 && o <= 57343 ? 4 : o < 65535 ? 3 : 4;
|
|
3054
3090
|
}
|
|
3055
3091
|
function de(o) {
|
|
@@ -3061,24 +3097,24 @@ function de(o) {
|
|
|
3061
3097
|
}
|
|
3062
3098
|
function F(o, t, e) {
|
|
3063
3099
|
if (!t || typeof t.line != "number" || typeof t.col != "number") return null;
|
|
3064
|
-
const i = o.getModel(), s =
|
|
3100
|
+
const i = o.getModel(), s = M(t.line + 1, 1, i?.getLineCount() || 1 / 0);
|
|
3065
3101
|
if (!i) {
|
|
3066
3102
|
const f = Math.max(1, t.col + 1);
|
|
3067
3103
|
return { lineNumber: s, column: f + (e ? 1 : 0) };
|
|
3068
3104
|
}
|
|
3069
3105
|
const n = i.getLineContent(s) ?? "", r = Math.max(0, Number(t.col) || 0);
|
|
3070
|
-
let
|
|
3106
|
+
let a = r;
|
|
3071
3107
|
if (e) {
|
|
3072
|
-
const f =
|
|
3108
|
+
const f = S(n, r);
|
|
3073
3109
|
if (f < n.length) {
|
|
3074
|
-
const
|
|
3075
|
-
|
|
3110
|
+
const l = n.codePointAt(f);
|
|
3111
|
+
a = r + L(l ?? 0);
|
|
3076
3112
|
}
|
|
3077
3113
|
}
|
|
3078
|
-
const
|
|
3079
|
-
return { lineNumber: s, column:
|
|
3114
|
+
const u = S(n, a) + 1, d = i.getLineMaxColumn(s);
|
|
3115
|
+
return { lineNumber: s, column: M(u, 1, d) };
|
|
3080
3116
|
}
|
|
3081
|
-
function
|
|
3117
|
+
function w(o) {
|
|
3082
3118
|
const t = typeof o == "string" ? o : "";
|
|
3083
3119
|
return t.includes("v") || t.includes("V") || t.includes("") || t.includes("s") || t.includes("S") || t.includes("");
|
|
3084
3120
|
}
|
|
@@ -3101,7 +3137,7 @@ function me(o, t) {
|
|
|
3101
3137
|
function H(o, t) {
|
|
3102
3138
|
const e = o.replace("#", "");
|
|
3103
3139
|
if (e.length !== 6) return o;
|
|
3104
|
-
const i = Math.round(
|
|
3140
|
+
const i = Math.round(M(t, 0, 1) * 255);
|
|
3105
3141
|
return `#${e}${i.toString(16).padStart(2, "0")}`;
|
|
3106
3142
|
}
|
|
3107
3143
|
function K(o) {
|
|
@@ -3112,7 +3148,7 @@ function K(o) {
|
|
|
3112
3148
|
function pe(o) {
|
|
3113
3149
|
return `#${Number(o >>> 0).toString(16).padStart(6, "0").slice(-6)}`;
|
|
3114
3150
|
}
|
|
3115
|
-
function
|
|
3151
|
+
function C(o, t, e, i) {
|
|
3116
3152
|
return o.addEventListener(t, e, i), { dispose: () => o.removeEventListener(t, e, i) };
|
|
3117
3153
|
}
|
|
3118
3154
|
function $(o) {
|
|
@@ -3123,22 +3159,22 @@ function ge(o) {
|
|
|
3123
3159
|
const t = typeof o == "string" ? o : "";
|
|
3124
3160
|
return t.length ? t[t.length - 1] : "";
|
|
3125
3161
|
}
|
|
3126
|
-
function
|
|
3162
|
+
function v(o) {
|
|
3127
3163
|
const t = typeof o == "string" ? o : "";
|
|
3128
3164
|
return t === "c" || t.startsWith("c");
|
|
3129
3165
|
}
|
|
3130
3166
|
function ye(o, t, e, i, s, n) {
|
|
3131
|
-
const r = o[t] ?? "",
|
|
3132
|
-
let
|
|
3133
|
-
if (
|
|
3134
|
-
|
|
3167
|
+
const r = o[t] ?? "", a = o[i] ?? "", u = r.slice(0, Math.max(0, e)), d = a.slice(Math.max(0, s)), l = String(n ?? "").split(/\r?\n/);
|
|
3168
|
+
let c;
|
|
3169
|
+
if (l.length <= 1)
|
|
3170
|
+
c = [`${u}${l[0] ?? ""}${d}`];
|
|
3135
3171
|
else {
|
|
3136
|
-
const
|
|
3137
|
-
|
|
3172
|
+
const h = `${u}${l[0] ?? ""}`, m = `${l[l.length - 1] ?? ""}${d}`, p = l.slice(1, -1);
|
|
3173
|
+
c = [h, ...p, m];
|
|
3138
3174
|
}
|
|
3139
|
-
o.splice(t, Math.max(0, i - t + 1), ...
|
|
3175
|
+
o.splice(t, Math.max(0, i - t + 1), ...c);
|
|
3140
3176
|
}
|
|
3141
|
-
function
|
|
3177
|
+
function T(o) {
|
|
3142
3178
|
if (!o) return "";
|
|
3143
3179
|
if (typeof o == "string") return o;
|
|
3144
3180
|
if (!Array.isArray(o)) return "";
|
|
@@ -3149,7 +3185,7 @@ function N(o) {
|
|
|
3149
3185
|
continue;
|
|
3150
3186
|
}
|
|
3151
3187
|
if (Array.isArray(e)) {
|
|
3152
|
-
typeof e[1] == "string" ? t += e[1] : typeof e[0] == "string" ? t += e[0] : t +=
|
|
3188
|
+
typeof e[1] == "string" ? t += e[1] : typeof e[0] == "string" ? t += e[0] : t += T(e);
|
|
3153
3189
|
continue;
|
|
3154
3190
|
}
|
|
3155
3191
|
e && typeof e == "object" && typeof e.text == "string" && (t += e.text);
|
|
@@ -3176,12 +3212,12 @@ function be(o) {
|
|
|
3176
3212
|
}
|
|
3177
3213
|
return t.filter((e) => e.word.length > 0);
|
|
3178
3214
|
}
|
|
3179
|
-
const
|
|
3215
|
+
const _e = new URL("./nvimWorker.js", import.meta.url), we = new URL("./nvimWorkerAsyncify.js", import.meta.url);
|
|
3180
3216
|
export {
|
|
3181
|
-
|
|
3217
|
+
le as MonacoNeovimClient,
|
|
3182
3218
|
te as NeovimWasmSession,
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3219
|
+
Ce as createMonacoNeovim,
|
|
3220
|
+
_e as defaultWorkerUrl,
|
|
3221
|
+
we as defaultWorkerUrlAsyncify,
|
|
3222
|
+
Z as isSharedArrayBufferAvailable
|
|
3187
3223
|
};
|