Skip to content

Commit 02dd400

Browse files
authored
Merge branch 'main' into merogge/task-timing
2 parents 99c5bed + d0d9701 commit 02dd400

36 files changed

+965
-134
lines changed

cli/src/tunnels.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pub mod shutdown_signal;
1212
pub mod singleton_client;
1313
pub mod singleton_server;
1414

15+
mod wsl_detect;
1516
mod challenge;
1617
mod control_server;
1718
mod nosleep;

cli/src/tunnels/dev_tunnels.rs

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
*--------------------------------------------------------------------------------------------*/
55
use crate::auth;
66
use crate::constants::{
7-
CONTROL_PORT, IS_INTERACTIVE_CLI, PROTOCOL_VERSION_TAG, PROTOCOL_VERSION_TAG_PREFIX,
8-
TUNNEL_SERVICE_USER_AGENT,
7+
CONTROL_PORT, IS_INTERACTIVE_CLI, PROTOCOL_VERSION_TAG, TUNNEL_SERVICE_USER_AGENT,
98
};
109
use crate::state::{LauncherPaths, PersistedState};
1110
use crate::util::errors::{
@@ -32,6 +31,8 @@ use tunnels::management::{
3231
NO_REQUEST_OPTIONS,
3332
};
3433

34+
use super::wsl_detect::is_wsl_installed;
35+
3536
#[derive(Clone, Serialize, Deserialize)]
3637
pub struct PersistedTunnel {
3738
pub name: String,
@@ -304,7 +305,7 @@ impl DevTunnels {
304305
return Ok((full_tunnel, persisted));
305306
}
306307

307-
full_tunnel.tags = vec![name.to_string(), VSCODE_CLI_TUNNEL_TAG.to_string()];
308+
full_tunnel.tags = self.get_tags(&name);
308309

309310
let new_tunnel = spanf!(
310311
self.log,
@@ -383,11 +384,9 @@ impl DevTunnels {
383384
}
384385
};
385386

386-
if !tunnel.tags.iter().any(|t| t == PROTOCOL_VERSION_TAG) {
387-
tunnel = self
388-
.update_protocol_version_tag(tunnel, &HOST_TUNNEL_REQUEST_OPTIONS)
389-
.await?;
390-
}
387+
tunnel = self
388+
.sync_tunnel_tags(&persisted.name, tunnel, &HOST_TUNNEL_REQUEST_OPTIONS)
389+
.await?;
391390

392391
let locator = TunnelLocator::try_from(&tunnel).unwrap();
393392
let host_token = get_host_token_from_tunnel(&tunnel);
@@ -504,23 +503,40 @@ impl DevTunnels {
504503
}
505504
}
506505

506+
/// Gets the expected tunnel tags
507+
fn get_tags(&self, name: &str) -> Vec<String> {
508+
let mut tags = vec![
509+
name.to_string(),
510+
PROTOCOL_VERSION_TAG.to_string(),
511+
VSCODE_CLI_TUNNEL_TAG.to_string(),
512+
];
513+
514+
if is_wsl_installed(&self.log) {
515+
tags.push("_wsl".to_string())
516+
}
517+
518+
tags
519+
}
520+
507521
/// Ensures the tunnel contains a tag for the current PROTCOL_VERSION, and no
508522
/// other version tags.
509-
async fn update_protocol_version_tag(
523+
async fn sync_tunnel_tags(
510524
&self,
525+
name: &str,
511526
tunnel: Tunnel,
512527
options: &TunnelRequestOptions,
513528
) -> Result<Tunnel, AnyError> {
529+
let new_tags = self.get_tags(name);
530+
if vec_eq_unsorted(&tunnel.tags, &new_tags) {
531+
return Ok(tunnel);
532+
}
533+
514534
debug!(
515535
self.log,
516-
"Updating tunnel protocol version tag to {}", PROTOCOL_VERSION_TAG
536+
"Updating tunnel tags {} -> {}",
537+
tunnel.tags.join(", "),
538+
new_tags.join(", ")
517539
);
518-
let mut new_tags: Vec<String> = tunnel
519-
.tags
520-
.into_iter()
521-
.filter(|t| !t.starts_with(PROTOCOL_VERSION_TAG_PREFIX))
522-
.collect();
523-
new_tags.push(PROTOCOL_VERSION_TAG.to_string());
524540

525541
let tunnel_update = Tunnel {
526542
tags: new_tags,
@@ -982,6 +998,20 @@ fn clean_hostname_for_tunnel(hostname: &str) -> String {
982998
}
983999
}
9841000

1001+
fn vec_eq_unsorted(a: &[String], b: &[String]) -> bool {
1002+
if a.len() != b.len() {
1003+
return false;
1004+
}
1005+
1006+
for item in a {
1007+
if !b.contains(item) {
1008+
return false;
1009+
}
1010+
}
1011+
1012+
true
1013+
}
1014+
9851015
#[cfg(test)]
9861016
mod test {
9871017
use super::*;

cli/src/tunnels/wsl_detect.rs

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
use crate::log;
7+
8+
#[cfg(not(windows))]
9+
pub fn is_wsl_installed(_log: &log::Logger) -> bool {
10+
false
11+
}
12+
13+
#[cfg(windows)]
14+
pub fn is_wsl_installed(log: &log::Logger) -> bool {
15+
use std::{path::PathBuf, process::Command};
16+
17+
let system32 = {
18+
let sys_root = match std::env::var("SystemRoot") {
19+
Ok(s) => s,
20+
Err(_) => return false,
21+
};
22+
23+
let is_32_on_64 = std::env::var("PROCESSOR_ARCHITEW6432").is_ok();
24+
let mut system32 = PathBuf::from(sys_root);
25+
system32.push(if is_32_on_64 { "Sysnative" } else { "System32" });
26+
system32
27+
};
28+
29+
// Windows builds < 22000
30+
let mut maybe_lxss = system32.join("lxss");
31+
maybe_lxss.push("LxssManager.dll");
32+
if maybe_lxss.exists() {
33+
trace!(log, "wsl availability detected via lxss");
34+
return true;
35+
}
36+
37+
// Windows builds >= 22000
38+
let maybe_wsl = system32.join("wsl.exe");
39+
if maybe_wsl.exists() {
40+
if let Ok(s) = Command::new(maybe_wsl).arg("--status").output() {
41+
if s.status.success() {
42+
trace!(log, "wsl availability detected via subprocess");
43+
return true;
44+
}
45+
}
46+
}
47+
48+
trace!(log, "wsl not detected");
49+
50+
false
51+
}

extensions/emmet/yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@
5959
integrity sha512-ua7PgUoeQFjmWPcoo9khiPum3Pd60k4/2ZGXt18sm2Slk0W0xZTqt5Y0Ny1NyBiN1EVQ/+FaF9NcY4Qe6rwk5w==
6060

6161
"@vscode/emmet-helper@^2.8.8":
62-
version "2.8.9"
63-
resolved "https://registry.yarnpkg.com/@vscode/emmet-helper/-/emmet-helper-2.8.9.tgz#536a2cba2f78b0dd25a874b85ab95f9b5424eb39"
64-
integrity sha512-ygpVStaePHt9aI9zk4NNJWI/NsRaeDSW1vQsZVmtpVRVCOdwYlsc3BfB/eppUu1OucT0x3OHDAzKcxnitjcSXQ==
62+
version "2.9.2"
63+
resolved "https://registry.yarnpkg.com/@vscode/emmet-helper/-/emmet-helper-2.9.2.tgz#cd5d1e64e7138ad76300e8cba5fd84f1c03e13ee"
64+
integrity sha512-MaGuyW+fa13q3aYsluKqclmh62Hgp0BpKIqS66fCxfOaBcVQ1OnMQxRRgQUYnCkxFISAQlkJ0qWWPyXjro1Qrg==
6565
dependencies:
6666
emmet "^2.4.3"
6767
jsonc-parser "^2.3.0"

extensions/vscode-api-tests/src/singlefolder-tests/workspace.fs.test.ts

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ suite('vscode API - workspace-fs', () => {
187187

188188
test('vscode.workspace.fs error reporting is weird #132981', async function () {
189189

190-
191190
const uri = await createRandomFile();
192191

193192
const source = vscode.Uri.joinPath(uri, `./${Math.random().toString(16).slice(2, 8)}`);
@@ -217,4 +216,48 @@ suite('vscode API - workspace-fs', () => {
217216
assert.strictEqual(err.code, 'FileNotFound');
218217
}
219218
});
219+
220+
test('fs.createFolder creates recursively', async function () {
221+
222+
const folder = root.with({ path: posix.join(root.path, 'deeply', 'nested', 'folder') });
223+
await vscode.workspace.fs.createDirectory(folder);
224+
225+
let stat = await vscode.workspace.fs.stat(folder);
226+
assert.strictEqual(stat.type, vscode.FileType.Directory);
227+
228+
await vscode.workspace.fs.delete(folder, { recursive: true, useTrash: false });
229+
230+
await vscode.workspace.fs.createDirectory(folder); // calling on existing folder is also ok!
231+
232+
const file = root.with({ path: posix.join(folder.path, 'file.txt') });
233+
await vscode.workspace.fs.writeFile(file, Buffer.from('Hello World'));
234+
const folder2 = root.with({ path: posix.join(file.path, 'invalid') });
235+
let e;
236+
try {
237+
await vscode.workspace.fs.createDirectory(folder2); // cannot create folder on file path
238+
} catch (error) {
239+
e = error;
240+
}
241+
assert.ok(e);
242+
243+
const folder3 = root.with({ path: posix.join(root.path, 'DEEPLY', 'NESTED', 'FOLDER') });
244+
await vscode.workspace.fs.createDirectory(folder3); // calling on different cased folder is ok!
245+
stat = await vscode.workspace.fs.stat(folder3);
246+
assert.strictEqual(stat.type, vscode.FileType.Directory);
247+
248+
await vscode.workspace.fs.delete(folder, { recursive: true, useTrash: false });
249+
});
250+
251+
test('fs.writeFile creates parents recursively', async function () {
252+
253+
const folder = root.with({ path: posix.join(root.path, 'other-deeply', 'nested', 'folder') });
254+
const file = root.with({ path: posix.join(folder.path, 'file.txt') });
255+
256+
await vscode.workspace.fs.writeFile(file, Buffer.from('Hello World'));
257+
258+
const stat = await vscode.workspace.fs.stat(file);
259+
assert.strictEqual(stat.type, vscode.FileType.File);
260+
261+
await vscode.workspace.fs.delete(folder, { recursive: true, useTrash: false });
262+
});
220263
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@
210210
"style-loader": "^3.3.2",
211211
"ts-loader": "^9.4.2",
212212
"ts-node": "^10.9.1",
213-
"tsec": "0.1.4",
213+
"tsec": "0.2.7",
214214
"typescript": "^5.2.0-dev.20230621",
215215
"typescript-formatter": "7.1.0",
216216
"underscore": "^1.12.1",

src/tsec.exemptions.json

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
{
2+
"ban-document-execcommand": [
3+
"vs/workbench/contrib/codeEditor/electron-sandbox/inputClipboardActions.ts",
4+
"vs/editor/contrib/clipboard/browser/clipboard.ts"
5+
],
26
"ban-eval-calls": [
37
"vs/workbench/api/worker/extHostExtensionService.ts",
4-
"vs/base/worker/workerMain"
8+
"vs/base/worker/workerMain.ts"
59
],
610
"ban-function-calls": [
711
"vs/workbench/api/worker/extHostExtensionService.ts",
8-
"vs/base/worker/workerMain",
12+
"vs/base/worker/workerMain.ts",
913
"vs/workbench/contrib/notebook/browser/view/renderers/webviewPreloads.ts",
1014
"vs/workbench/services/keybinding/test/node/keyboardMapperTestUtils.ts"
1115
],
@@ -18,8 +22,19 @@
1822
"vs/base/browser/defaultWorkerFactory.ts",
1923
"vs/workbench/services/extensions/browser/webWorkerExtensionHost.ts"
2024
],
25+
"ban-worker-importscripts": [
26+
"vs/workbench/services/extensions/worker/polyfillNestedWorker.ts",
27+
"vs/workbench/api/worker/extensionHostWorker.ts",
28+
"vs/base/worker/workerMain.ts"
29+
],
2130
"ban-domparser-parsefromstring": [
2231
"vs/base/browser/markdownRenderer.ts",
2332
"vs/base/test/browser/markdownRenderer.test.ts"
33+
],
34+
"ban-element-setattribute": [
35+
"**/*.ts"
36+
],
37+
"ban-element-insertadjacenthtml": [
38+
"**/*.ts"
2439
]
2540
}

src/vs/editor/browser/widget/diffEditorWidget2/diffEditorWidget2.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,9 @@ export class DiffEditorWidget2 extends DelegatingEditor implements IDiffEditor {
7777
@ICodeEditorService codeEditorService: ICodeEditorService,
7878
) {
7979
super();
80-
8180
codeEditorService.willCreateDiffEditor();
8281

83-
this._contextKeyService.createKey(EditorContextKeys.inDiffEditor.key, true);
82+
this._contextKeyService.createKey('isInDiffEditor', true);
8483
this._contextKeyService.createKey('diffEditorVersion', 2);
8584

8685
this._options = new DiffEditorOptions(options);

src/vs/workbench/api/common/extHost.api.impl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
10201020
registerFileSystemProvider(scheme, provider, options) {
10211021
return combinedDisposable(
10221022
extHostFileSystem.registerFileSystemProvider(extension, scheme, provider, options),
1023-
extHostConsumerFileSystem.addFileSystemProvider(scheme, provider)
1023+
extHostConsumerFileSystem.addFileSystemProvider(scheme, provider, options)
10241024
);
10251025
},
10261026
get fs() {

0 commit comments

Comments
 (0)