Commit ff7d11f
authored
fix: open a device folder's workspace, and keep it (#383)
The Android picker is ACTION_OPEN_DOCUMENT_TREE and returns a directory,
never a file, so a workspace on device storage can only be reached through
the folder holding it. Nothing joined the two. The folder opened as a folder,
and the `.code-workspace` in it was reachable only by knowing to find the
file in the explorer and press the button on it; desktop VS Code offers that
step itself, from code the browser workbench does not carry. A granted folder
holding exactly one workspace file now opens as that workspace. Two is left
as a folder rather than guessed at, and a directory merely named like one is
excluded, because the workbench answers a workspace it cannot read with an
empty window and no message.
Pressing that button did not work either. It navigates the workbench to
`?workspace=<file>`, which the shell could not read: folderFromUrl parsed
only `folder` and required a directory, so both consumers of the page-load
callback were skipped. The workspace was not remembered and the next launch
fell through to the default projects directory, and adoptWorkbenchFolder
never ran, so a workspace opened out of a device-folder mirror got no
write-back watcher and every edit stayed in the mirror instead of reaching
the user's own files, with nothing on screen to say so.
workbenchUrl now names a workspace file with `workspace=` and everything else
with `folder=`, so a remembered workspace round-trips. folderFromUrl reads
both parameters through workbenchTarget, which stats each for the kind of
thing it is. The remembered path may now be a file, so its existence test is
exists() rather than isDirectory. resourceRootsInForce publishes the
directory holding a workspace rather than the file, which as a path prefix
would match only itself and refuse every resource beside it.
A closed folder was the same defect one state over. `?ew=true` is the third
thing the workbench can be showing and the folder chain cannot name it, so a
renderer crash over a closed folder reopened the workspace the user had just
closed. Those paths now restore the URL rather than rebuild one, which is
what handleResumeFromBackground already did for the same reason.
The saf-bridge extension also contributes Open Recent Folder to the status
bar remote indicator, the device picker having been reachable only by typing
its name into the command palette. Its directory moves to 1.5.0 because the
server caches the extension scan against the extensions root mtime, which
editing a manifest in place does not change.
The user guide said to open folders with File > Open Folder, which browses
the app's own storage and cannot reach Documents, Downloads or an SD card,
and FR-FS-05 claimed multi-root workspaces without qualification. Both now
say what the code does.
Verified on emulators at API 33 and API 37: granting Documents/wsdemo opens
it as `proj (Workspace)` with both roots, the edit that stayed in the mirror
now reaches the device folder, the workspace survives a cold start and a
renderer crash, a closed folder stays closed across one, and removing a
mirror while its workspace is open is still refused. A root the workspace
lists outside the granted folder is drawn in the warning colour rather than
failing silently, which is why none is guarded against.
Closes #3811 parent b451c56 commit ff7d11f
10 files changed
Lines changed: 484 additions & 14 deletions
File tree
- android/app/src
- main
- assets/extensions/vscodroid.vscodroid-saf-bridge-1.5.0
- kotlin/com/vscodroid
- webview
- test/kotlin/com/vscodroid
- setup
- webview
- docs
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
293 | | - | |
| 293 | + | |
294 | 294 | | |
295 | 295 | | |
296 | 296 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
62 | 66 | | |
63 | 67 | | |
64 | 68 | | |
| |||
Lines changed: 153 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1230 | 1230 | | |
1231 | 1231 | | |
1232 | 1232 | | |
1233 | | - | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
1234 | 1237 | | |
1235 | | - | |
| 1238 | + | |
| 1239 | + | |
| 1240 | + | |
| 1241 | + | |
| 1242 | + | |
| 1243 | + | |
| 1244 | + | |
| 1245 | + | |
| 1246 | + | |
| 1247 | + | |
1236 | 1248 | | |
1237 | 1249 | | |
1238 | 1250 | | |
| |||
2303 | 2315 | | |
2304 | 2316 | | |
2305 | 2317 | | |
2306 | | - | |
| 2318 | + | |
2307 | 2319 | | |
2308 | 2320 | | |
2309 | 2321 | | |
2310 | 2322 | | |
2311 | 2323 | | |
| 2324 | + | |
| 2325 | + | |
| 2326 | + | |
| 2327 | + | |
| 2328 | + | |
| 2329 | + | |
| 2330 | + | |
| 2331 | + | |
| 2332 | + | |
| 2333 | + | |
2312 | 2334 | | |
2313 | 2335 | | |
2314 | 2336 | | |
| |||
2387 | 2409 | | |
2388 | 2410 | | |
2389 | 2411 | | |
2390 | | - | |
2391 | | - | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
| 2416 | + | |
| 2417 | + | |
| 2418 | + | |
| 2419 | + | |
2392 | 2420 | | |
2393 | 2421 | | |
2394 | 2422 | | |
| |||
2675 | 2703 | | |
2676 | 2704 | | |
2677 | 2705 | | |
2678 | | - | |
| 2706 | + | |
| 2707 | + | |
| 2708 | + | |
| 2709 | + | |
| 2710 | + | |
2679 | 2711 | | |
2680 | 2712 | | |
2681 | 2713 | | |
| |||
3537 | 3569 | | |
3538 | 3570 | | |
3539 | 3571 | | |
3540 | | - | |
| 3572 | + | |
3541 | 3573 | | |
3542 | 3574 | | |
3543 | 3575 | | |
| |||
4258 | 4290 | | |
4259 | 4291 | | |
4260 | 4292 | | |
4261 | | - | |
| 4293 | + | |
| 4294 | + | |
4262 | 4295 | | |
4263 | 4296 | | |
4264 | 4297 | | |
| 4298 | + | |
| 4299 | + | |
| 4300 | + | |
| 4301 | + | |
| 4302 | + | |
| 4303 | + | |
| 4304 | + | |
| 4305 | + | |
| 4306 | + | |
| 4307 | + | |
| 4308 | + | |
| 4309 | + | |
| 4310 | + | |
| 4311 | + | |
| 4312 | + | |
| 4313 | + | |
| 4314 | + | |
| 4315 | + | |
| 4316 | + | |
| 4317 | + | |
| 4318 | + | |
| 4319 | + | |
| 4320 | + | |
| 4321 | + | |
| 4322 | + | |
| 4323 | + | |
| 4324 | + | |
| 4325 | + | |
| 4326 | + | |
| 4327 | + | |
| 4328 | + | |
| 4329 | + | |
| 4330 | + | |
| 4331 | + | |
| 4332 | + | |
| 4333 | + | |
| 4334 | + | |
| 4335 | + | |
| 4336 | + | |
| 4337 | + | |
| 4338 | + | |
| 4339 | + | |
| 4340 | + | |
| 4341 | + | |
| 4342 | + | |
| 4343 | + | |
| 4344 | + | |
| 4345 | + | |
| 4346 | + | |
| 4347 | + | |
| 4348 | + | |
| 4349 | + | |
| 4350 | + | |
| 4351 | + | |
| 4352 | + | |
| 4353 | + | |
| 4354 | + | |
| 4355 | + | |
| 4356 | + | |
| 4357 | + | |
| 4358 | + | |
| 4359 | + | |
| 4360 | + | |
| 4361 | + | |
| 4362 | + | |
| 4363 | + | |
| 4364 | + | |
| 4365 | + | |
| 4366 | + | |
| 4367 | + | |
| 4368 | + | |
| 4369 | + | |
| 4370 | + | |
| 4371 | + | |
| 4372 | + | |
| 4373 | + | |
| 4374 | + | |
| 4375 | + | |
| 4376 | + | |
| 4377 | + | |
| 4378 | + | |
| 4379 | + | |
| 4380 | + | |
| 4381 | + | |
| 4382 | + | |
| 4383 | + | |
| 4384 | + | |
| 4385 | + | |
| 4386 | + | |
| 4387 | + | |
| 4388 | + | |
| 4389 | + | |
| 4390 | + | |
| 4391 | + | |
| 4392 | + | |
| 4393 | + | |
| 4394 | + | |
| 4395 | + | |
| 4396 | + | |
| 4397 | + | |
| 4398 | + | |
| 4399 | + | |
| 4400 | + | |
| 4401 | + | |
| 4402 | + | |
| 4403 | + | |
| 4404 | + | |
| 4405 | + | |
| 4406 | + | |
| 4407 | + | |
| 4408 | + | |
| 4409 | + | |
4265 | 4410 | | |
4266 | 4411 | | |
4267 | 4412 | | |
| |||
Lines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
196 | 197 | | |
197 | 198 | | |
198 | 199 | | |
199 | | - | |
| 200 | + | |
200 | 201 | | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
201 | 209 | | |
202 | 210 | | |
203 | 211 | | |
| |||
0 commit comments