@sparkelf/dsh-patch-wsl-native-open 0.2.0-rc.17 → 0.2.0-rc.19
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/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
diff --git a/packages/host/open-in-app/src/icons.ts b/packages/host/open-in-app/src/icons.ts
|
|
2
|
-
index
|
|
2
|
+
index 6908ce795b..570dc45c96 100644
|
|
3
3
|
--- a/packages/host/open-in-app/src/icons.ts
|
|
4
4
|
+++ b/packages/host/open-in-app/src/icons.ts
|
|
5
5
|
@@ -97,6 +97,41 @@ const EXTRACT_ICON_PS1 = [
|
|
@@ -73,7 +73,7 @@ index 6908ce7..570dc45 100644
|
|
|
73
73
|
return desktopId === undefined ? null : extractLinuxIcon(desktopId, completed)
|
|
74
74
|
}
|
|
75
75
|
diff --git a/packages/host/open-in-app/src/resolver.ts b/packages/host/open-in-app/src/resolver.ts
|
|
76
|
-
index
|
|
76
|
+
index 7ab964b4fd..8ea7318975 100644
|
|
77
77
|
--- a/packages/host/open-in-app/src/resolver.ts
|
|
78
78
|
+++ b/packages/host/open-in-app/src/resolver.ts
|
|
79
79
|
@@ -14,10 +14,10 @@
|
|
@@ -164,7 +164,7 @@ index 7ab964b..8ea7318 100644
|
|
|
164
164
|
return found === null
|
|
165
165
|
? null
|
|
166
166
|
diff --git a/packages/util/native-command/src/index.ts b/packages/util/native-command/src/index.ts
|
|
167
|
-
index
|
|
167
|
+
index a2e23a35be..f1ea7c6233 100644
|
|
168
168
|
--- a/packages/util/native-command/src/index.ts
|
|
169
169
|
+++ b/packages/util/native-command/src/index.ts
|
|
170
170
|
@@ -6,6 +6,7 @@
|
|
@@ -176,10 +176,18 @@ index a2e23a3..f1ea7c6 100644
|
|
|
176
176
|
nativeFileManager,
|
|
177
177
|
revealNativePath,
|
|
178
178
|
diff --git a/packages/util/native-command/src/path-opener.ts b/packages/util/native-command/src/path-opener.ts
|
|
179
|
-
index
|
|
179
|
+
index 8f3443b3c1..3962fd8523 100644
|
|
180
180
|
--- a/packages/util/native-command/src/path-opener.ts
|
|
181
181
|
+++ b/packages/util/native-command/src/path-opener.ts
|
|
182
|
-
@@ -
|
|
182
|
+
@@ -11,7 +11,6 @@
|
|
183
|
+
|
|
184
|
+
import { release as osRelease } from 'node:os'
|
|
185
|
+
import { dirname, extname } from 'node:path'
|
|
186
|
+
-import { pathToFileURL } from 'node:url'
|
|
187
|
+
import { runNativeCommand, type NativeCommandRunner } from './runner.ts'
|
|
188
|
+
|
|
189
|
+
/** Testable command boundary; native implementations never invoke a shell. */
|
|
190
|
+
@@ -99,13 +98,49 @@ function isWsl(internals: PathOpenerInternals): boolean {
|
|
183
191
|
return (internals.osRelease ?? osRelease()).toLowerCase().includes('microsoft')
|
|
184
192
|
}
|
|
185
193
|
|
|
@@ -231,7 +239,7 @@ index 8f3443b..79e7ace 100644
|
|
|
231
239
|
}
|
|
232
240
|
|
|
233
241
|
/** Translate a WSL path before handing it to the Windows desktop. */
|
|
234
|
-
@@ -154,6 +
|
|
242
|
+
@@ -154,6 +189,25 @@ async function openNativePathWithIntent(
|
|
235
243
|
throw new Error(`native path opener is unsupported on ${platform}`)
|
|
236
244
|
}
|
|
237
245
|
|
|
@@ -257,3 +265,20 @@ index 8f3443b..79e7ace 100644
|
|
|
257
265
|
/**
|
|
258
266
|
* Whether {@link openNativePath} plausibly reaches a desktop on this host.
|
|
259
267
|
*
|
|
268
|
+
@@ -244,10 +298,13 @@ export async function revealNativePath(
|
|
269
|
+
windowsPath = translated.stdout.replace(/[\r\n]+$/, '')
|
|
270
|
+
if (windowsPath === '') throw new Error('wslpath returned no Windows path')
|
|
271
|
+
}
|
|
272
|
+
- // Explorer parses commas itself; a file URI preserves commas and whitespace in the path.
|
|
273
|
+
- const target = pathToFileURL(windowsPath, { windows: true }).href.replaceAll(',', '%2C')
|
|
274
|
+
+ // Explorer takes the path itself: `wslpath -w` already produced the spelling it reads.
|
|
275
|
+
+ // A `file://` URL is not interchangeable here — a percent-encoded non-ASCII path (a CJK
|
|
276
|
+
+ // directory such as 题库) fails to resolve, and Explorer then opens its default location
|
|
277
|
+
+ // instead of selecting the file. Measured with a directory it had never opened: the native
|
|
278
|
+
+ // path selected 子目录/测试文件.txt, the URL form changed nothing.
|
|
279
|
+
try {
|
|
280
|
+
- await run('explorer.exe', ['/select,', target], signal)
|
|
281
|
+
+ await run('explorer.exe', ['/select,', windowsPath], signal)
|
|
282
|
+
} catch (error) {
|
|
283
|
+
signal.throwIfAborted()
|
|
284
|
+
// Explorer can exit 1 after delegating to the existing desktop process.
|