dsh-remote-vs 0.24.0 → 0.26.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +50 -16
- package/README.md +40 -15
- package/THIRD-PARTY-NOTICES.md +188 -0
- package/lib/client.js +6512 -77887
- package/lib/index.js +1461 -1024
- package/lib/p2-router-fs.js +1 -1
- package/lib/types/client/CodeEditor.d.ts +25 -0
- package/lib/types/client/EditorPane.d.ts +16 -5
- package/lib/types/client/FloatingPlaceholder.d.ts +16 -5
- package/lib/types/client/RemoteEditorView.d.ts +13 -10
- package/lib/types/client/RemoteExplorer.d.ts +53 -0
- package/lib/types/client/RemoteRoot.d.ts +5 -5
- package/lib/types/client/TerminalSnippets.d.ts +36 -0
- package/lib/types/client/TerminalView.d.ts +1 -1
- package/lib/types/client/XTerm.d.ts +33 -0
- package/lib/types/client/api.d.ts +37 -2
- package/lib/types/client/changes/review-state.d.ts +19 -0
- package/lib/types/client/connection.d.ts +16 -0
- package/lib/types/client/editor-capability.d.ts +27 -0
- package/lib/types/client/i18n.d.ts +1 -1
- package/lib/types/client/request-gate.d.ts +110 -0
- package/lib/types/client/scm/DiffView.d.ts +45 -7
- package/lib/types/client/scm/actions.d.ts +31 -3
- package/lib/types/client/store.d.ts +112 -4
- package/lib/types/client/terminal-input.d.ts +23 -0
- package/lib/types/client/terminal-snippets.d.ts +86 -0
- package/lib/types/client/vsc/FindWidget.d.ts +6 -0
- package/lib/types/client/vsc/breadcrumb.d.ts +30 -0
- package/lib/types/client/vsc/change-marks.d.ts +16 -6
- package/lib/types/client/vsc/editor-caret.d.ts +32 -0
- package/lib/types/client/vsc/editor-keymap.d.ts +35 -1
- package/lib/types/client/vsc/editor-langs.d.ts +9 -0
- package/lib/types/client/vsc/editor-settings.d.ts +55 -0
- package/lib/types/client/vsc/image-preview.d.ts +36 -0
- package/lib/types/client/vsc/kit.d.ts +13 -0
- package/lib/types/client/vsc/save-shortcut.d.ts +21 -0
- package/lib/types/client/vsc/terminal-clipboard.d.ts +15 -0
- package/lib/types/client/vsc/terminal-line.d.ts +25 -0
- package/lib/types/client/vsc/terminal-links.d.ts +62 -0
- package/lib/types/client/vsc/terminal-theme.d.ts +48 -0
- package/lib/types/client/vsc/terminal-writer.d.ts +52 -0
- package/lib/types/forward.d.ts +12 -0
- package/lib/types/fs-ops.d.ts +42 -0
- package/lib/types/http.d.ts +2 -0
- package/lib/types/keygen.d.ts +9 -0
- package/lib/types/monitor.d.ts +8 -0
- package/lib/types/notices.d.ts +16 -1
- package/lib/types/p2/helper-rpc.d.ts +45 -0
- package/lib/types/pool.d.ts +25 -0
- package/lib/types/routes.d.ts +2 -0
- package/lib/types/store.d.ts +7 -0
- package/lib/types/terminal.d.ts +33 -1
- package/lib/types/view-settings.d.ts +5 -0
- package/lib/{worlds-B7gEDBzC.js → worlds-RG8K5eom.js} +113 -15
- package/package.json +2 -1
- package/src/client/CodeEditor.tsx +205 -10
- package/src/client/DirectoryFlow.tsx +16 -0
- package/src/client/DoctorPanel.tsx +70 -7
- package/src/client/EditorPane.tsx +545 -118
- package/src/client/FloatingPlaceholder.tsx +34 -5
- package/src/client/HostsView.tsx +12 -3
- package/src/client/RemoteDirectoryPicker.tsx +12 -0
- package/src/client/RemoteEditorView.tsx +14 -11
- package/src/client/RemoteExplorer.tsx +929 -40
- package/src/client/RemoteRoot.tsx +167 -147
- package/src/client/SearchView.tsx +8 -0
- package/src/client/TerminalSnippets.tsx +432 -0
- package/src/client/TerminalView.tsx +50 -1
- package/src/client/XTerm.tsx +228 -58
- package/src/client/api.ts +106 -13
- package/src/client/auto-open-remote.ts +11 -9
- package/src/client/changes/ChangesDock.tsx +188 -6
- package/src/client/changes/changes.css +10 -3
- package/src/client/changes/review-state.ts +34 -0
- package/src/client/connection.ts +29 -0
- package/src/client/downloads.ts +49 -4
- package/src/client/editor-capability.ts +42 -0
- package/src/client/i18n.ts +228 -12
- package/src/client/index.tsx +22 -6
- package/src/client/request-gate.ts +221 -0
- package/src/client/scm/CommitPane.tsx +20 -2
- package/src/client/scm/DiffView.tsx +343 -117
- package/src/client/scm/HistoryPanel.tsx +23 -2
- package/src/client/scm/RepoPicker.tsx +1 -1
- package/src/client/scm/ScmPanel.tsx +391 -87
- package/src/client/scm/actions.ts +95 -12
- package/src/client/store.tsx +537 -22
- package/src/client/terminal-input.ts +44 -0
- package/src/client/terminal-snippets.ts +216 -0
- package/src/client/ui.tsx +4 -0
- package/src/client/vsc/FindWidget.tsx +24 -9
- package/src/client/vsc/breadcrumb.tsx +339 -0
- package/src/client/vsc/change-marks.ts +93 -44
- package/src/client/vsc/editor-caret.ts +30 -0
- package/src/client/vsc/editor-keymap.ts +59 -1
- package/src/client/vsc/editor-langs.ts +20 -0
- package/src/client/vsc/editor-settings.ts +146 -0
- package/src/client/vsc/editor-theme.ts +4 -5
- package/src/client/vsc/file-icons.tsx +17 -3
- package/src/client/vsc/image-preview.tsx +110 -0
- package/src/client/vsc/kit.tsx +46 -10
- package/src/client/vsc/save-shortcut.ts +47 -1
- package/src/client/vsc/terminal-clipboard.ts +19 -0
- package/src/client/vsc/terminal-line.ts +101 -0
- package/src/client/vsc/terminal-links.ts +166 -0
- package/src/client/vsc/terminal-theme.ts +97 -0
- package/src/client/vsc/terminal-writer.ts +112 -0
- package/src/client/vsc/vsc.css +1078 -181
- package/src/forward.ts +47 -9
- package/src/fs-ops.ts +124 -4
- package/src/git-ops.ts +20 -3
- package/src/http.ts +35 -4
- package/src/keygen.ts +55 -4
- package/src/monitor.ts +13 -0
- package/src/notices.ts +23 -1
- package/src/p2/helper-rpc.ts +113 -7
- package/src/p2/worlds.ts +14 -1
- package/src/pool.ts +99 -27
- package/src/routes.ts +212 -43
- package/src/sftp.ts +51 -14
- package/src/store.ts +10 -0
- package/src/terminal.ts +225 -24
- package/src/view-settings.ts +50 -10
- package/lib/types/client/Dialog.d.ts +0 -14
- package/src/client/Dialog.tsx +0 -76
|
@@ -17333,8 +17333,14 @@ var RemoteFiles = class {
|
|
|
17333
17333
|
});
|
|
17334
17334
|
this.trackPartial(alias, partial);
|
|
17335
17335
|
const size = await streamIntoFile(sftp, partial, source, maxBytes);
|
|
17336
|
-
if (overwrite)
|
|
17337
|
-
|
|
17336
|
+
if (overwrite) {
|
|
17337
|
+
const targetStat = await lstatAsync(sftp, path).catch((error) => {
|
|
17338
|
+
if (error.code === SFTP_NO_SUCH_FILE) return void 0;
|
|
17339
|
+
throw error;
|
|
17340
|
+
});
|
|
17341
|
+
if (targetStat !== void 0 && (typeof targetStat.isDirectory === "function" ? targetStat.isDirectory() : (targetStat.mode & 61440) === 16384)) throw new Error(`not a file: ${path} is a directory`);
|
|
17342
|
+
await replaceFile(sftp, partial, path);
|
|
17343
|
+
} else await renameAsync(sftp, partial, path);
|
|
17338
17344
|
this.forgetPartial(alias, partial);
|
|
17339
17345
|
this.remember(this.knownDirs, dirKey(alias, dir));
|
|
17340
17346
|
await this.sweepOrphanDirs(sftp, alias, dir);
|
|
@@ -17477,8 +17483,8 @@ var RemoteFiles = class {
|
|
|
17477
17483
|
await mkdirAsync(sftp, path);
|
|
17478
17484
|
} catch (error) {
|
|
17479
17485
|
const code = error.code;
|
|
17480
|
-
if (code !==
|
|
17481
|
-
|
|
17486
|
+
if (code !== SFTP_FAILURE && code !== void 0) throw error;
|
|
17487
|
+
try {
|
|
17482
17488
|
await lstatAsync(sftp, path);
|
|
17483
17489
|
} catch {
|
|
17484
17490
|
throw error;
|
|
@@ -17692,7 +17698,10 @@ async function explainSftpFailure(sftp, path, wanted, cause) {
|
|
|
17692
17698
|
const code = cause?.code;
|
|
17693
17699
|
if (code !== SFTP_NO_SUCH_FILE && code !== SFTP_FAILURE) return void 0;
|
|
17694
17700
|
const kind = await pathKind(sftp, path);
|
|
17695
|
-
if (kind.kind === "missing")
|
|
17701
|
+
if (kind.kind === "missing") {
|
|
17702
|
+
const hint = code === SFTP_FAILURE ? " (the server reported only status 4: this can also be a permission or disk-space problem)" : "";
|
|
17703
|
+
return /* @__PURE__ */ new Error(wanted === "directory" ? `no such directory: ${path}${hint}` : `no such file: ${path}${hint}`);
|
|
17704
|
+
}
|
|
17696
17705
|
if (wanted === "directory" && kind.kind !== "dir") return /* @__PURE__ */ new Error(`not a directory: ${path} is ${describeKind(kind)}`);
|
|
17697
17706
|
if (wanted === "file" && kind.kind === "dir") return /* @__PURE__ */ new Error(`not a file: ${path} is a directory`);
|
|
17698
17707
|
}
|
|
@@ -19006,7 +19015,28 @@ function pushHostNotice(notice) {
|
|
|
19006
19015
|
if (pending.length >= MAX_PENDING$1) return;
|
|
19007
19016
|
pending = [...pending, notice];
|
|
19008
19017
|
}
|
|
19009
|
-
/**
|
|
19018
|
+
/**
|
|
19019
|
+
* Take the notices queued for ONE host alias.
|
|
19020
|
+
*
|
|
19021
|
+
* A response only reports news about the host it is about. Draining the whole
|
|
19022
|
+
* queue from whichever response was written first delivered host A's helper
|
|
19023
|
+
* push into a window looking at host B — and consumed it, so A never saw it.
|
|
19024
|
+
* Notices for other aliases stay queued for a response about their host.
|
|
19025
|
+
*/
|
|
19026
|
+
function takeHostNotices(alias) {
|
|
19027
|
+
if (pending.length === 0) return [];
|
|
19028
|
+
const taken = pending.filter((notice) => notice.alias === alias);
|
|
19029
|
+
if (taken.length === 0) return [];
|
|
19030
|
+
pending = pending.filter((notice) => notice.alias !== alias);
|
|
19031
|
+
return taken;
|
|
19032
|
+
}
|
|
19033
|
+
/**
|
|
19034
|
+
* Take everything queued (no host filtering).
|
|
19035
|
+
*
|
|
19036
|
+
* Kept for callers that own the whole queue — the offline probes reset it, and
|
|
19037
|
+
* a response written OUTSIDE the route table has no host to filter by
|
|
19038
|
+
* (`src/http.ts` keeps that historical drain-all answer).
|
|
19039
|
+
*/
|
|
19010
19040
|
function drainHostNotices() {
|
|
19011
19041
|
if (pending.length === 0) return [];
|
|
19012
19042
|
const drained = pending;
|
|
@@ -19191,6 +19221,21 @@ var RpcConnection = class {
|
|
|
19191
19221
|
dead;
|
|
19192
19222
|
disposed = false;
|
|
19193
19223
|
/**
|
|
19224
|
+
* Transport generation, bumped by every teardown.
|
|
19225
|
+
*
|
|
19226
|
+
* ssh2 does not close synchronously: `Channel.close()` is a PROTOCOL message
|
|
19227
|
+
* and `Client.end()`'s socket 'close' arrives later. Those late
|
|
19228
|
+
* 'close'/'error' events used to call `invalidate()` after `reconnect()` had
|
|
19229
|
+
* already cleared `dead`, marking the BRAND-NEW dial dead: `open()` then
|
|
19230
|
+
* released the fresh transport and the retry rejected with the OLD
|
|
19231
|
+
* transport's error (probe T6 measured exactly this — a close 5 ms late, a
|
|
19232
|
+
* new dial 20 ms). Every transport callback therefore captures the generation
|
|
19233
|
+
* it was created under and compares it before acting; a teardown invalidates
|
|
19234
|
+
* every callback of the transport it releases, without removing listeners
|
|
19235
|
+
* (ssh2 offers no per-callback unsubscribe that would survive a destroy).
|
|
19236
|
+
*/
|
|
19237
|
+
generation = 0;
|
|
19238
|
+
/**
|
|
19194
19239
|
* The helper's own error output, kept so its reason survives.
|
|
19195
19240
|
*
|
|
19196
19241
|
* Nothing read this stream before, so a helper that died on startup took its
|
|
@@ -19223,11 +19268,13 @@ var RpcConnection = class {
|
|
|
19223
19268
|
let attempt = 0;
|
|
19224
19269
|
for (;;) {
|
|
19225
19270
|
const peer = await this.peerReady();
|
|
19271
|
+
const generation = this.generation;
|
|
19226
19272
|
await this.gate.acquire(signal);
|
|
19227
19273
|
try {
|
|
19228
19274
|
return await this.withDeadline(peer.request(method, params, schema, signal), method, mutating);
|
|
19229
19275
|
} catch (error) {
|
|
19230
19276
|
if (!(error instanceof HelperTimeoutError)) throw error;
|
|
19277
|
+
if (generation !== this.generation) throw error;
|
|
19231
19278
|
this.invalidate(error);
|
|
19232
19279
|
if (mutating || attempt >= 1) throw error;
|
|
19233
19280
|
attempt += 1;
|
|
@@ -19273,6 +19320,7 @@ var RpcConnection = class {
|
|
|
19273
19320
|
async dispose() {
|
|
19274
19321
|
if (this.disposed) return;
|
|
19275
19322
|
this.disposed = true;
|
|
19323
|
+
if (this.peer === void 0 && this.channel === void 0 && this.conn !== void 0) return;
|
|
19276
19324
|
this.teardownTransport();
|
|
19277
19325
|
}
|
|
19278
19326
|
async peerReady() {
|
|
@@ -19290,8 +19338,13 @@ var RpcConnection = class {
|
|
|
19290
19338
|
* `stderrTail` is cleared too: it describes the connection being torn down, and
|
|
19291
19339
|
* keeping it would attribute the NEXT failure to the previous transport's error
|
|
19292
19340
|
* output.
|
|
19341
|
+
*
|
|
19342
|
+
* The generation bump comes FIRST: the close calls below can emit their events
|
|
19343
|
+
* synchronously, and anything this transport has queued must already count as
|
|
19344
|
+
* stale by then.
|
|
19293
19345
|
*/
|
|
19294
19346
|
teardownTransport() {
|
|
19347
|
+
this.generation += 1;
|
|
19295
19348
|
if (this.heartbeat !== void 0) {
|
|
19296
19349
|
clearTimeout(this.heartbeat);
|
|
19297
19350
|
this.heartbeat = void 0;
|
|
@@ -19310,7 +19363,12 @@ var RpcConnection = class {
|
|
|
19310
19363
|
const conn = new import_lib.Client();
|
|
19311
19364
|
this.conn = conn;
|
|
19312
19365
|
try {
|
|
19313
|
-
|
|
19366
|
+
const hello = await this.dialAndHello(conn);
|
|
19367
|
+
if (this.dead !== void 0 || this.disposed) {
|
|
19368
|
+
this.teardownTransport();
|
|
19369
|
+
throw this.dead ?? /* @__PURE__ */ new Error("helper RPC was disposed");
|
|
19370
|
+
}
|
|
19371
|
+
return hello;
|
|
19314
19372
|
} catch (error) {
|
|
19315
19373
|
this.teardownTransport();
|
|
19316
19374
|
throw error;
|
|
@@ -19319,6 +19377,7 @@ var RpcConnection = class {
|
|
|
19319
19377
|
/** The part of {@link open} that runs once the socket object exists. */
|
|
19320
19378
|
async dialAndHello(conn) {
|
|
19321
19379
|
const { entry } = this.opts;
|
|
19380
|
+
const generation = this.generation;
|
|
19322
19381
|
await new Promise((resolve, reject) => {
|
|
19323
19382
|
let settled = false;
|
|
19324
19383
|
conn.on("ready", () => {
|
|
@@ -19331,10 +19390,14 @@ var RpcConnection = class {
|
|
|
19331
19390
|
if (!settled) {
|
|
19332
19391
|
settled = true;
|
|
19333
19392
|
reject(error);
|
|
19334
|
-
} else this.invalidate(error);
|
|
19393
|
+
} else if (generation === this.generation) this.invalidate(error);
|
|
19335
19394
|
});
|
|
19336
19395
|
conn.on("close", () => {
|
|
19337
|
-
|
|
19396
|
+
if (!settled) {
|
|
19397
|
+
settled = true;
|
|
19398
|
+
reject(/* @__PURE__ */ new Error("ssh connection closed before it became ready"));
|
|
19399
|
+
}
|
|
19400
|
+
if (generation === this.generation) this.invalidate(/* @__PURE__ */ new Error("ssh connection closed"));
|
|
19338
19401
|
});
|
|
19339
19402
|
try {
|
|
19340
19403
|
if (entry.auth.kind === "key") conn.connect({
|
|
@@ -19369,13 +19432,14 @@ var RpcConnection = class {
|
|
|
19369
19432
|
});
|
|
19370
19433
|
this.channel = channel;
|
|
19371
19434
|
channel.stderr.on("data", (chunk) => {
|
|
19435
|
+
if (generation !== this.generation) return;
|
|
19372
19436
|
this.stderrTail = (this.stderrTail + chunk.toString("utf8")).slice(-2e3);
|
|
19373
19437
|
});
|
|
19374
19438
|
channel.on("close", () => {
|
|
19375
|
-
this.invalidate(/* @__PURE__ */ new Error("helper channel closed"));
|
|
19439
|
+
if (generation === this.generation) this.invalidate(/* @__PURE__ */ new Error("helper channel closed"));
|
|
19376
19440
|
});
|
|
19377
19441
|
channel.on("error", (error) => {
|
|
19378
|
-
this.invalidate(error);
|
|
19442
|
+
if (generation === this.generation) this.invalidate(error);
|
|
19379
19443
|
});
|
|
19380
19444
|
const leaseMs = this.opts.leaseMs ?? 3e4;
|
|
19381
19445
|
const peer = new SshRpcPeer(channel, channel, MAX_FRAME, MAX_PENDING);
|
|
@@ -19390,9 +19454,10 @@ var RpcConnection = class {
|
|
|
19390
19454
|
if (hello.hash !== this.opts.helperHash) throw new Error("helper digest differs from the deployed artifact");
|
|
19391
19455
|
if (hello.bootstrapHash !== void 0) throw new Error("helper reported an unexpected PTC bootstrap digest");
|
|
19392
19456
|
const beat = () => {
|
|
19393
|
-
if (this.disposed || this.dead !== void 0) return;
|
|
19457
|
+
if (this.disposed || generation !== this.generation || this.dead !== void 0) return;
|
|
19394
19458
|
this.heartbeat = setTimeout(() => {
|
|
19395
19459
|
peer.request("heartbeat", {}, z.null(), AbortSignal.timeout(Math.floor(leaseMs / 2))).catch((error) => {
|
|
19460
|
+
if (generation !== this.generation) return;
|
|
19396
19461
|
this.invalidate(error instanceof Error ? error : new Error(String(error)));
|
|
19397
19462
|
}).finally(beat);
|
|
19398
19463
|
}, Math.floor(leaseMs / 3));
|
|
@@ -19407,13 +19472,45 @@ var RpcConnection = class {
|
|
|
19407
19472
|
nodeVersion: hello.nodeVersion
|
|
19408
19473
|
};
|
|
19409
19474
|
}
|
|
19475
|
+
/**
|
|
19476
|
+
* Mark the connection dead AND release its transport.
|
|
19477
|
+
*
|
|
19478
|
+
* Closing the peer alone was not enough: `SshRpcPeer.close()` destroys the
|
|
19479
|
+
* exec streams, and ssh2's `Channel.destroy()` does not end the `Client` that
|
|
19480
|
+
* carries them — so the session stayed open (30s keepalive and all) while its
|
|
19481
|
+
* owner had already written it off as dead. One leaked socket per invalidation,
|
|
19482
|
+
* until the process exits. `teardownTransport()` is the only path that ends the
|
|
19483
|
+
* Client, so an invalidated connection goes through it too; that is safe to
|
|
19484
|
+
* repeat because each field is cleared as it is closed and `closeQuietly`
|
|
19485
|
+
* ignores a second close — a later `dispose()`, `reconnect()` or failed
|
|
19486
|
+
* `open()` teardown therefore finds nothing left to release.
|
|
19487
|
+
*
|
|
19488
|
+
* Ordering is deliberate: the peer is closed FIRST so in-flight requests reject
|
|
19489
|
+
* with THIS error (the teardown's own close would raise a generic
|
|
19490
|
+
* "channel closed" instead), and `stderrTail` is captured BEFORE the teardown,
|
|
19491
|
+
* which clears it — otherwise `diagnostics` in the dial path would always
|
|
19492
|
+
* report "the helper wrote nothing to stderr".
|
|
19493
|
+
*
|
|
19494
|
+
* Only an ESTABLISHED transport is released here. While `open()` is still
|
|
19495
|
+
* dialing, `conn` is alive and `channel`/`peer` are not, and ending that Client
|
|
19496
|
+
* would strand the handshake: ssh2 clears its own ready timer when the socket
|
|
19497
|
+
* closes and emits 'close' without an 'error', so the promise `open()` awaits
|
|
19498
|
+
* would never settle. `open()` itself releases the attempt instead, once it has
|
|
19499
|
+
* a definitive outcome.
|
|
19500
|
+
*/
|
|
19410
19501
|
invalidate(error) {
|
|
19411
19502
|
if (this.dead !== void 0 || this.disposed) return;
|
|
19412
19503
|
this.dead = error;
|
|
19413
|
-
if (this.heartbeat !== void 0)
|
|
19504
|
+
if (this.heartbeat !== void 0) {
|
|
19505
|
+
clearTimeout(this.heartbeat);
|
|
19506
|
+
this.heartbeat = void 0;
|
|
19507
|
+
}
|
|
19508
|
+
const tail = this.stderrTail;
|
|
19414
19509
|
try {
|
|
19415
19510
|
this.peer?.close(error);
|
|
19416
19511
|
} catch {}
|
|
19512
|
+
if (this.peer !== void 0 || this.channel !== void 0) this.teardownTransport();
|
|
19513
|
+
this.stderrTail = tail;
|
|
19417
19514
|
}
|
|
19418
19515
|
};
|
|
19419
19516
|
//#endregion
|
|
@@ -19953,9 +20050,10 @@ var RemoteWorlds = class {
|
|
|
19953
20050
|
}
|
|
19954
20051
|
const conn = await pending;
|
|
19955
20052
|
if (!conn.alive) {
|
|
20053
|
+
const detail = conn.diagnostics;
|
|
20054
|
+
conn.dispose().catch(() => void 0);
|
|
19956
20055
|
this.rpcs.delete(alias);
|
|
19957
20056
|
if (attempt < DIAL_IMMEDIATE_RETRIES) return this.dial(alias, attempt + 1);
|
|
19958
|
-
const detail = conn.diagnostics;
|
|
19959
20057
|
const reason = "helper connection closed right after dialing" + (detail === "" ? " (the helper wrote nothing to stderr)" : ` — helper stderr: ${detail}`);
|
|
19960
20058
|
this.noteDialFailure(alias, new Error(reason));
|
|
19961
20059
|
throw new Error(`helper RPC for ${alias} is unavailable after ${attempt + 1} attempt(s): ${reason}`);
|
|
@@ -20051,4 +20149,4 @@ var RemoteWorlds = class {
|
|
|
20051
20149
|
}
|
|
20052
20150
|
};
|
|
20053
20151
|
//#endregion
|
|
20054
|
-
export {
|
|
20152
|
+
export { dshHome as C, viewSettingsPath as D, storePath as E, aliasRoot as S, keysDir as T, MAX_TIMEOUT_MS as _, takeHostNotices as a, resolveTimeouts as b, pushPipeline as c, WriteConflictError as d, attachmentHeader as f, DeadlineError as g, DEFAULT_TIMEOUTS as h, drainHostNotices as i, seedHelperCache as l, DEFAULT_READ_TIMEOUT_MS as m, TombstonedError as n, helperAvailability as o, DEFAULT_GIT_TIMEOUT_MS as p, isWindowsAbsolute as r, probe as s, RemoteWorlds as t, RemoteFiles as u, MIN_TIMEOUT_MS as v, ensurePrivateDir as w, require_lib as x, clampExecTimeout as y };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-remote-vs",
|
|
3
3
|
"description": "VSCode-style remote development for DSH: SSH host manager (key/password), helper deploy pipeline with version check, remote file explorer + editor + terminal in dsh-better-sidebar.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.26.0",
|
|
5
5
|
"icon": "icon.svg",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"dsh",
|
|
@@ -83,6 +83,7 @@
|
|
|
83
83
|
"cordis.patch.yml",
|
|
84
84
|
"README.md",
|
|
85
85
|
"README.en.md",
|
|
86
|
+
"THIRD-PARTY-NOTICES.md",
|
|
86
87
|
"LICENSE",
|
|
87
88
|
"icon.svg",
|
|
88
89
|
"locale/*.json"
|
|
@@ -6,19 +6,21 @@
|
|
|
6
6
|
* local viewer's twin — see selection-popup.ts); the payload is a fenced
|
|
7
7
|
* `rel:lines` block inserted into the on-screen session's composer draft.
|
|
8
8
|
*/
|
|
9
|
-
import { forwardRef, useEffect, useImperativeHandle, useRef, useState, type ReactNode } from 'react'
|
|
9
|
+
import { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState, type ReactNode } from 'react'
|
|
10
10
|
import { createPortal } from 'react-dom'
|
|
11
11
|
import type { Context } from '@deepseek-ai/cordis'
|
|
12
12
|
import { EditorSelection, EditorState, StateEffect, StateField, Compartment, type Extension, type Text } from '@codemirror/state'
|
|
13
|
-
import { Decoration, EditorView, highlightActiveLine, keymap, lineNumbers, type DecorationSet } from '@codemirror/view'
|
|
13
|
+
import { Decoration, EditorView, drawSelection, highlightActiveLine, keymap, lineNumbers, type DecorationSet } from '@codemirror/view'
|
|
14
14
|
import { history } from '@codemirror/commands'
|
|
15
15
|
import { bracketMatching, ensureSyntaxTree, indentOnInput } from '@codemirror/language'
|
|
16
16
|
import { closeBrackets } from '@codemirror/autocomplete'
|
|
17
|
-
import { search } from '@codemirror/search'
|
|
17
|
+
import { search, selectNextOccurrence } from '@codemirror/search'
|
|
18
18
|
import { syntaxHighlighting } from '@codemirror/language'
|
|
19
19
|
import { vscodeHighlightStyle } from './vsc/editor-palette.ts'
|
|
20
20
|
import { FindWidget, clearFindMarks, findMatchHighlight, stepFind } from './vsc/FindWidget.tsx'
|
|
21
|
-
import { editorKeymap } from './vsc/editor-keymap.ts'
|
|
21
|
+
import { editorKeymap, parseGotoLine } from './vsc/editor-keymap.ts'
|
|
22
|
+
import { promptDialog, toast } from './vsc/kit.tsx'
|
|
23
|
+
import { isModalLayerOpen } from './vsc/save-shortcut.ts'
|
|
22
24
|
import { javascript } from '@codemirror/lang-javascript'
|
|
23
25
|
import { python } from '@codemirror/lang-python'
|
|
24
26
|
import { json } from '@codemirror/lang-json'
|
|
@@ -38,6 +40,7 @@ import { diff } from '@codemirror/legacy-modes/mode/diff'
|
|
|
38
40
|
import { buildRemoteSelectionInsert, insertReferenceOrText, type PendingReference } from './composer.ts'
|
|
39
41
|
import { useSelectionPopup } from './selection-popup.ts'
|
|
40
42
|
import { initialEditorTheme, watchEditorScheme } from './vsc/editor-theme.ts'
|
|
43
|
+
import { detectLang, makeT } from './i18n.ts'
|
|
41
44
|
|
|
42
45
|
/**
|
|
43
46
|
* The bits of an editor's view state that must survive an unmount.
|
|
@@ -58,6 +61,9 @@ export interface CodeEditorViewState {
|
|
|
58
61
|
ranges: { anchor: number; head: number }[]
|
|
59
62
|
}
|
|
60
63
|
|
|
64
|
+
export { caretOf, type CodeEditorCaret } from './vsc/editor-caret.ts'
|
|
65
|
+
import { caretOf as caretOfState, type CodeEditorCaret as CodeEditorCaretType } from './vsc/editor-caret.ts'
|
|
66
|
+
|
|
61
67
|
export interface CodeEditorHandle {
|
|
62
68
|
getContent: () => string
|
|
63
69
|
isDirty: () => boolean
|
|
@@ -103,6 +109,17 @@ const fallbackCompartment = new Compartment()
|
|
|
103
109
|
*/
|
|
104
110
|
const readOnlyCompartment = new Compartment()
|
|
105
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Compartment holding the word-wrap flag.
|
|
114
|
+
*
|
|
115
|
+
* Same reasoning as the read-only one: the preference is changed from the
|
|
116
|
+
* editor's own toolbar / status bar while the buffer is mounted, and remounting
|
|
117
|
+
* to flip it would throw away the undo history and the caret. `undefined` (a
|
|
118
|
+
* caller that never passed the prop, e.g. a diff pane) keeps the historical
|
|
119
|
+
* behaviour of wrapping.
|
|
120
|
+
*/
|
|
121
|
+
const wrapCompartment = new Compartment()
|
|
122
|
+
|
|
106
123
|
/**
|
|
107
124
|
* Compartment holding the session-change marks.
|
|
108
125
|
*
|
|
@@ -144,6 +161,29 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
144
161
|
readOnly?: boolean
|
|
145
162
|
/** Parent sub-tab visibility (views stay mounted; remeasure on show). */
|
|
146
163
|
visible?: boolean
|
|
164
|
+
/**
|
|
165
|
+
* Translator for the editor's own chrome (find widget + change marks).
|
|
166
|
+
*
|
|
167
|
+
* Optional so callers that do not own the dictionary (diff panes) keep
|
|
168
|
+
* working: the fallback makes the same `detectLang()` choice the store does,
|
|
169
|
+
* so the copy matches the language of the rest of the pane.
|
|
170
|
+
*/
|
|
171
|
+
t?: (key: string) => string
|
|
172
|
+
/**
|
|
173
|
+
* Soft wrap long lines.
|
|
174
|
+
*
|
|
175
|
+
* `undefined` = the historical behaviour (wrap on) for callers that do not
|
|
176
|
+
* own the preference (diff panes); `false` turns it off.
|
|
177
|
+
*/
|
|
178
|
+
wrap?: boolean
|
|
179
|
+
/**
|
|
180
|
+
* Reports the 1-based caret line/column plus the selected character count.
|
|
181
|
+
*
|
|
182
|
+
* The status bar needs it and CodeMirror only exposes selection changes
|
|
183
|
+
* through an update listener, so the editor reports instead of the parent
|
|
184
|
+
* polling a ref. Called once with the initial position, then on every move.
|
|
185
|
+
*/
|
|
186
|
+
onCaretChange?: (caret: CodeEditorCaretType) => void
|
|
147
187
|
/** Chat-insert target: absent/disabled hides the selection popup. */
|
|
148
188
|
ctx?: Context
|
|
149
189
|
sessionId?: string | undefined
|
|
@@ -251,6 +291,10 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
251
291
|
const dirtyRef = useRef<boolean>(false)
|
|
252
292
|
const propsRef = useRef(props)
|
|
253
293
|
propsRef.current = props
|
|
294
|
+
// Resolved once per mount: `detectLang()` is a page-level decision (the same
|
|
295
|
+
// one the store makes), so the identity is stable and safe in effect deps.
|
|
296
|
+
const fallbackT = useMemo(() => makeT(detectLang()), [])
|
|
297
|
+
const t = props.t ?? fallbackT
|
|
254
298
|
// The CodeMirror selection listener lives for the mount's lifetime; the
|
|
255
299
|
// chat target may change underneath it (session switches don't remount
|
|
256
300
|
// the editor), so it reads through refs, never captured props.
|
|
@@ -344,10 +388,19 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
344
388
|
*/
|
|
345
389
|
const armedRef = useRef('')
|
|
346
390
|
const pushedSetRef = useRef<ChangeSet | null | undefined>(undefined)
|
|
391
|
+
/**
|
|
392
|
+
* `changeMarksExtension` 的 gutter/chip 文案在安装时按 `t` 解析,所以语言换了
|
|
393
|
+
* 要和「能力翻转」一样重装一次 compartment。
|
|
394
|
+
*/
|
|
395
|
+
const labelsRef = useRef(t)
|
|
347
396
|
const undoArmed = props.onUndoChange !== undefined
|
|
348
397
|
useEffect(() => {
|
|
349
398
|
const current = viewRef.current
|
|
350
399
|
if (current === undefined) return
|
|
400
|
+
if (labelsRef.current !== t) {
|
|
401
|
+
labelsRef.current = t
|
|
402
|
+
armedRef.current = ''
|
|
403
|
+
}
|
|
351
404
|
const set = props.changeSet
|
|
352
405
|
const marks = set !== undefined
|
|
353
406
|
const armed = `${marks ? 'm' : ''}${undoArmed ? 'u' : ''}`
|
|
@@ -356,7 +409,7 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
356
409
|
// 重装扩展会重建字段,之前下发过的数据随之消失,必须再喂一次。
|
|
357
410
|
pushedSetRef.current = undefined
|
|
358
411
|
const extension: Extension = [
|
|
359
|
-
...(marks ? [changeMarksExtension] : []),
|
|
412
|
+
...(marks ? [changeMarksExtension(t)] : []),
|
|
360
413
|
...(undoArmed
|
|
361
414
|
? [undoAffordance({
|
|
362
415
|
onUndo: (mark) => { propsRef.current.onUndoChange?.(mark) },
|
|
@@ -378,7 +431,7 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
378
431
|
} catch {
|
|
379
432
|
// Disposed.
|
|
380
433
|
}
|
|
381
|
-
}, [props.changeSet, undoArmed, view])
|
|
434
|
+
}, [props.changeSet, undoArmed, view, t])
|
|
382
435
|
|
|
383
436
|
/**
|
|
384
437
|
* 跳到某个改动点。
|
|
@@ -425,6 +478,14 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
425
478
|
const host = hostRef.current
|
|
426
479
|
if (host === null) return
|
|
427
480
|
const rect = host.getBoundingClientRect()
|
|
481
|
+
// The surface can disappear while the widget is open (the preview swap
|
|
482
|
+
// hides the editor host with `display:none`). Close BEFORE positioning:
|
|
483
|
+
// a zero box would otherwise compute `right = innerWidth + 18` and shove
|
|
484
|
+
// the box out of the viewport, where Esc can no longer reach it.
|
|
485
|
+
if (rect.width === 0 || rect.height === 0) {
|
|
486
|
+
setFindOpen(false)
|
|
487
|
+
return
|
|
488
|
+
}
|
|
428
489
|
const next = {
|
|
429
490
|
top: Math.max(4, rect.top + 6),
|
|
430
491
|
right: Math.max(8, window.innerWidth - rect.right + 18),
|
|
@@ -449,6 +510,49 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
449
510
|
}
|
|
450
511
|
}, [findOpen])
|
|
451
512
|
|
|
513
|
+
/**
|
|
514
|
+
* Find widget lifecycle follows the editor surface.
|
|
515
|
+
*
|
|
516
|
+
* The widget is a `document.body` portal, so it does NOT live in the editor's
|
|
517
|
+
* DOM tree: when the surface it belongs to goes away (a Markdown/HTML preview
|
|
518
|
+
* swap, a hidden pane, a surface that left the viewport entirely) the box used
|
|
519
|
+
* to survive on screen with its 350 ms anchor poll still running — and Esc
|
|
520
|
+
* only works while its input has focus, so the user had to switch back to
|
|
521
|
+
* source just to close it.
|
|
522
|
+
*
|
|
523
|
+
* Closing is the same state flip Esc and the ✕ use (`setFindOpen(false)`), so
|
|
524
|
+
* the effect above drops the match marks and clears the poll through their
|
|
525
|
+
* existing path. Nothing here reopens it: when the surface comes back the user
|
|
526
|
+
* gets Ctrl+F again, but a widget they left behind does not pop up by itself.
|
|
527
|
+
*/
|
|
528
|
+
useEffect(() => {
|
|
529
|
+
if (!findOpen) return
|
|
530
|
+
// The parent's own answer for "this surface is mounted but not shown".
|
|
531
|
+
if (props.visible === false) {
|
|
532
|
+
setFindOpen(false)
|
|
533
|
+
return
|
|
534
|
+
}
|
|
535
|
+
const host = hostRef.current
|
|
536
|
+
if (host === null) return
|
|
537
|
+
// Geometry the parent cannot see: the preview swap puts `display:none` on
|
|
538
|
+
// the editor host without touching `visible`.
|
|
539
|
+
const rect = host.getBoundingClientRect()
|
|
540
|
+
if (rect.width === 0 || rect.height === 0) {
|
|
541
|
+
setFindOpen(false)
|
|
542
|
+
return
|
|
543
|
+
}
|
|
544
|
+
// Catch layout changes that emit no scroll/resize event (the preview swap,
|
|
545
|
+
// an ancestor collapsing). Absent in the jsdom harnesses, hence the guard.
|
|
546
|
+
if (typeof IntersectionObserver === 'undefined') return
|
|
547
|
+
const observer = new IntersectionObserver((entries) => {
|
|
548
|
+
if (entries.some(entry => !entry.isIntersecting)) setFindOpen(false)
|
|
549
|
+
})
|
|
550
|
+
observer.observe(host)
|
|
551
|
+
return () => {
|
|
552
|
+
observer.disconnect()
|
|
553
|
+
}
|
|
554
|
+
}, [findOpen, props.visible])
|
|
555
|
+
|
|
452
556
|
/**
|
|
453
557
|
* Note on the SCROLL report: it is wired up INSIDE the mount effect below,
|
|
454
558
|
* where the view is created — not in an effect of its own. An earlier version
|
|
@@ -540,6 +644,20 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
540
644
|
view.dispatch({ effects: readOnlyCompartment.reconfigure(EditorState.readOnly.of(props.readOnly === true)) })
|
|
541
645
|
}, [props.readOnly])
|
|
542
646
|
|
|
647
|
+
/**
|
|
648
|
+
* Word wrap follows the shared editor preference, live.
|
|
649
|
+
*
|
|
650
|
+
* A reconfigure (not a remount) so flipping the toolbar / status-bar toggle
|
|
651
|
+
* keeps the undo history and the caret exactly where they were.
|
|
652
|
+
*/
|
|
653
|
+
useEffect(() => {
|
|
654
|
+
const view = viewRef.current
|
|
655
|
+
if (view === undefined) return
|
|
656
|
+
view.dispatch({
|
|
657
|
+
effects: wrapCompartment.reconfigure(props.wrap === false ? [] : EditorView.lineWrapping),
|
|
658
|
+
})
|
|
659
|
+
}, [props.wrap])
|
|
660
|
+
|
|
543
661
|
// Shown again after being hidden: remeasure layout.
|
|
544
662
|
useEffect(() => {
|
|
545
663
|
if (props.visible === false) return
|
|
@@ -588,8 +706,32 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
588
706
|
if (host === null) return
|
|
589
707
|
const extensions: Extension[] = [
|
|
590
708
|
history(),
|
|
591
|
-
|
|
592
|
-
|
|
709
|
+
/**
|
|
710
|
+
* Multi-range selections (Ctrl/Cmd+D's repeated "select next occurrence",
|
|
711
|
+
* and the stock Mod-Alt-Arrow cursor commands).
|
|
712
|
+
*
|
|
713
|
+
* Required, not cosmetic: without this facet `Transaction.state` collapses
|
|
714
|
+
* EVERY selection to its main range (`EditorSelection.asSingle`), so
|
|
715
|
+
* `selectNextOccurrence` reports success while nothing visible is added —
|
|
716
|
+
* the shortcut would look broken. The tab view-state code already carries
|
|
717
|
+
* multiple ranges across a remount, so this is the same model, enabled.
|
|
718
|
+
*/
|
|
719
|
+
EditorState.allowMultipleSelections.of(true),
|
|
720
|
+
// The facet above keeps the RANGES; `drawSelection` is what paints every
|
|
721
|
+
// secondary cursor and every non-main selection. Without it Ctrl+D changes
|
|
722
|
+
// the document on ranges the user cannot see (jsdom probes: the selection
|
|
723
|
+
// layer was null and one keystroke edited three ranges at once).
|
|
724
|
+
drawSelection(),
|
|
725
|
+
keymap.of(editorKeymap({
|
|
726
|
+
// The SAME modal gate the window-level listener applies (`save-shortcut.ts`):
|
|
727
|
+
// CodeMirror handles Mod-s first and prevents the default, so this callback —
|
|
728
|
+
// not that listener — is the one that decides while the editor has focus. A
|
|
729
|
+
// modal layer (host approval/settings, our confirm card, a menu) must not be
|
|
730
|
+
// written through; see editor-keymap's `EditorKeyHandlers.save` contract.
|
|
731
|
+
save: () => {
|
|
732
|
+
if (isModalLayerOpen()) return
|
|
733
|
+
propsRef.current.onSave()
|
|
734
|
+
},
|
|
593
735
|
openFindForSelection: (view) => {
|
|
594
736
|
const sel = view.state.selection.main
|
|
595
737
|
if (!sel.empty) {
|
|
@@ -614,7 +756,50 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
614
756
|
setFindOpen(false)
|
|
615
757
|
return true
|
|
616
758
|
},
|
|
617
|
-
|
|
759
|
+
/**
|
|
760
|
+
* Ctrl/Cmd+G: the prompt is ours (see `editor-keymap.ts`), because the
|
|
761
|
+
* stock `gotoLine` command renders CodeMirror's own search panel and
|
|
762
|
+
* this editor never mounts it. The jump reuses the same reveal helper a
|
|
763
|
+
* search hit uses: clamp to the document, put the caret there, light the
|
|
764
|
+
* landing line.
|
|
765
|
+
*/
|
|
766
|
+
gotoLine: (view) => {
|
|
767
|
+
void (async () => {
|
|
768
|
+
// Named with the `T` suffix the i18n key scanner accepts: the lookup
|
|
769
|
+
// must stay VISIBLE to `.spike/i18n-check`, or the three keys would
|
|
770
|
+
// later read as "defined but unreferenced" once they are added.
|
|
771
|
+
const editorT = propsRef.current.t ?? fallbackT
|
|
772
|
+
const total = view.state.doc.lines
|
|
773
|
+
const current = view.state.doc.lineAt(view.state.selection.main.head).number
|
|
774
|
+
const answer = await promptDialog({
|
|
775
|
+
title: editorT('editor.gotoLine'),
|
|
776
|
+
text: editorT('editor.gotoLineText').replace('{total}', String(total)),
|
|
777
|
+
initial: String(current),
|
|
778
|
+
})
|
|
779
|
+
if (answer === undefined) return
|
|
780
|
+
const target = parseGotoLine(answer, total)
|
|
781
|
+
if (target === undefined) {
|
|
782
|
+
toast(editorT('editor.gotoLineInvalid'), true)
|
|
783
|
+
return
|
|
784
|
+
}
|
|
785
|
+
// The prompt is async: the tab may have switched (or the surface
|
|
786
|
+
// unmounted) while it was open, and a disposed view must not be
|
|
787
|
+
// dispatched into.
|
|
788
|
+
if (viewRef.current !== view) return
|
|
789
|
+
revealLine(view, target, setLitPosition)
|
|
790
|
+
})()
|
|
791
|
+
},
|
|
792
|
+
/**
|
|
793
|
+
* Ctrl/Cmd+D: `@codemirror/search`'s command, verbatim. It only moves
|
|
794
|
+
* selections (never the document), so it is safe in the read-only views
|
|
795
|
+
* the diff panes mount; its false answer is returned so the key can fall
|
|
796
|
+
* through instead of being swallowed (see `editor-keymap.ts`).
|
|
797
|
+
*/
|
|
798
|
+
selectNextOccurrence: (view) => selectNextOccurrence({
|
|
799
|
+
state: view.state,
|
|
800
|
+
dispatch: transaction => view.dispatch(transaction),
|
|
801
|
+
}),
|
|
802
|
+
})),
|
|
618
803
|
lineNumbers(),
|
|
619
804
|
highlightActiveLine(),
|
|
620
805
|
indentOnInput(),
|
|
@@ -639,7 +824,7 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
639
824
|
// Session-change marks, off until a `changeSet` prop arrives (see
|
|
640
825
|
// `changeMarksCompartment`).
|
|
641
826
|
changeMarksCompartment.of([]),
|
|
642
|
-
EditorView.lineWrapping,
|
|
827
|
+
wrapCompartment.of(propsRef.current.wrap === false ? [] : EditorView.lineWrapping),
|
|
643
828
|
readOnlyCompartment.of(EditorState.readOnly.of(propsRef.current.readOnly === true)),
|
|
644
829
|
...langFor(propsRef.current.path),
|
|
645
830
|
EditorView.updateListener.of((update) => {
|
|
@@ -730,6 +915,10 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
730
915
|
// than a new extension, and gated on `findOpenRef` so the widget being
|
|
731
916
|
// closed never costs a render.
|
|
732
917
|
if (findOpenRef.current) setFindTick(tick => tick + 1)
|
|
918
|
+
// Status-bar readout: reported BEFORE the view-state handoff below,
|
|
919
|
+
// which returns early for callers that keep no tab state (diff panes).
|
|
920
|
+
const caretHandler = propsRef.current.onCaretChange
|
|
921
|
+
if (caretHandler !== undefined) caretHandler(caretOfState(update.state))
|
|
733
922
|
const handler = propsRef.current.onViewState
|
|
734
923
|
const tabId = propsRef.current.tabId
|
|
735
924
|
if (handler === undefined || tabId === undefined) return
|
|
@@ -777,6 +966,11 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
777
966
|
}
|
|
778
967
|
}
|
|
779
968
|
setView(view)
|
|
969
|
+
// The status bar starts at the caret's real position instead of line 1/col
|
|
970
|
+
// 1: a remount restores the selection further down (see the restore block
|
|
971
|
+
// below), and no selection event fires for a caret that never moved.
|
|
972
|
+
const initialCaret = propsRef.current.onCaretChange
|
|
973
|
+
if (initialCaret !== undefined) initialCaret(caretOfState(view.state))
|
|
780
974
|
/**
|
|
781
975
|
* Come back to where this file was left.
|
|
782
976
|
*
|
|
@@ -1015,6 +1209,7 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
|
|
|
1015
1209
|
<FindWidget
|
|
1016
1210
|
view={view}
|
|
1017
1211
|
open={findOpen}
|
|
1212
|
+
t={t}
|
|
1018
1213
|
seed={findSeed}
|
|
1019
1214
|
tick={findTick}
|
|
1020
1215
|
anchor={anchor}
|
|
@@ -237,6 +237,8 @@ function LocalLeg(props: {
|
|
|
237
237
|
value={draft}
|
|
238
238
|
onChange={(e) => setDraft(e.target.value)}
|
|
239
239
|
onKeyDown={(e) => {
|
|
240
|
+
// IME candidate Enter must not navigate to a half-composed path.
|
|
241
|
+
if (e.nativeEvent.isComposing === true || e.keyCode === 229) return
|
|
240
242
|
if (e.key === 'Enter') go()
|
|
241
243
|
}}
|
|
242
244
|
disabled={blocked}
|
|
@@ -254,7 +256,19 @@ function LocalLeg(props: {
|
|
|
254
256
|
{(listing?.entries ?? []).filter((e) => !e.hidden).map((entry) => (
|
|
255
257
|
<div
|
|
256
258
|
key={entry.path}
|
|
259
|
+
// Same fix as the standalone picker (audit I-10): Enter/Space enter
|
|
260
|
+
// the directory. While a browse is in flight the row is inert, so it
|
|
261
|
+
// is taken out of the tab order instead of silently doing nothing.
|
|
262
|
+
role="button"
|
|
263
|
+
tabIndex={blocked ? -1 : 0}
|
|
264
|
+
aria-disabled={blocked === true ? true : undefined}
|
|
257
265
|
onClick={() => { if (!blocked) void browse(entry.path) }}
|
|
266
|
+
onKeyDown={(e) => {
|
|
267
|
+
if (blocked) return
|
|
268
|
+
if (e.key !== 'Enter' && e.key !== ' ') return
|
|
269
|
+
e.preventDefault()
|
|
270
|
+
void browse(entry.path)
|
|
271
|
+
}}
|
|
258
272
|
title={entry.path}
|
|
259
273
|
style={{ display: 'flex', gap: 6, alignItems: 'center', padding: '3px 8px', borderRadius: 4, cursor: blocked ? 'default' : 'pointer', fontSize: 13 }}
|
|
260
274
|
onMouseEnter={(e) => {
|
|
@@ -284,6 +298,8 @@ function LocalLeg(props: {
|
|
|
284
298
|
value={mkdirName}
|
|
285
299
|
onChange={(e) => setMkdirName(e.target.value)}
|
|
286
300
|
onKeyDown={(e) => {
|
|
301
|
+
// IME candidate Enter must not create a folder from a half-composed name.
|
|
302
|
+
if (e.nativeEvent.isComposing === true || e.keyCode === 229) return
|
|
287
303
|
if (e.key === 'Enter') mkdir()
|
|
288
304
|
}}
|
|
289
305
|
placeholder={t('flow.mkdirName')}
|