Skip to content

Commit 860f46c

Browse files
authored
Merge branch 'main' into merogge/notification
2 parents 2839ea0 + 3d1f720 commit 860f46c

File tree

37 files changed

+953
-978
lines changed

37 files changed

+953
-978
lines changed

cli/src/bin/code/main.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ async fn main() -> Result<(), std::convert::Infallible> {
9595
args::VersionSubcommand::Show => version::show(context!()).await,
9696
},
9797

98-
Some(args::Commands::CommandShell) => tunnels::command_shell(context!()).await,
98+
Some(args::Commands::CommandShell(cs_args)) => {
99+
tunnels::command_shell(context!(), cs_args).await
100+
}
99101

100102
Some(args::Commands::Tunnel(tunnel_args)) => match tunnel_args.subcommand {
101103
Some(args::TunnelSubcommand::Prune) => tunnels::prune(context!()).await,

cli/src/commands/args.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,14 @@ pub enum Commands {
174174

175175
/// Runs the control server on process stdin/stdout
176176
#[clap(hide = true)]
177-
CommandShell,
177+
CommandShell(CommandShellArgs),
178+
}
179+
180+
#[derive(Args, Debug, Clone)]
181+
pub struct CommandShellArgs {
182+
/// Listen on a socket instead of stdin/stdout.
183+
#[clap(long)]
184+
pub on_socket: bool,
178185
}
179186

180187
#[derive(Args, Debug, Clone)]

cli/src/commands/tunnels.rs

Lines changed: 51 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,22 @@
55

66
use async_trait::async_trait;
77
use base64::{engine::general_purpose as b64, Engine as _};
8+
use futures::{stream::FuturesUnordered, StreamExt};
89
use serde::Serialize;
910
use sha2::{Digest, Sha256};
1011
use std::{str::FromStr, time::Duration};
1112
use sysinfo::Pid;
1213

1314
use super::{
1415
args::{
15-
AuthProvider, CliCore, ExistingTunnelArgs, TunnelRenameArgs, TunnelServeArgs,
16-
TunnelServiceSubCommands, TunnelUserSubCommands,
16+
AuthProvider, CliCore, CommandShellArgs, ExistingTunnelArgs, TunnelRenameArgs,
17+
TunnelServeArgs, TunnelServiceSubCommands, TunnelUserSubCommands,
1718
},
1819
CommandContext,
1920
};
2021

2122
use crate::{
23+
async_pipe::{get_socket_name, listen_socket_rw_stream, socket_stream_split},
2224
auth::Auth,
2325
constants::{APPLICATION_NAME, TUNNEL_CLI_LOCK_NAME, TUNNEL_SERVICE_LOCK_NAME},
2426
log,
@@ -120,23 +122,55 @@ impl ServiceContainer for TunnelServiceContainer {
120122
}
121123
}
122124

123-
pub async fn command_shell(ctx: CommandContext) -> Result<i32, AnyError> {
125+
pub async fn command_shell(ctx: CommandContext, args: CommandShellArgs) -> Result<i32, AnyError> {
124126
let platform = PreReqChecker::new().verify().await?;
125-
serve_stream(
126-
tokio::io::stdin(),
127-
tokio::io::stderr(),
128-
ServeStreamParams {
129-
log: ctx.log,
130-
launcher_paths: ctx.paths,
131-
platform,
132-
requires_auth: true,
133-
exit_barrier: ShutdownRequest::create_rx([ShutdownRequest::CtrlC]),
134-
code_server_args: (&ctx.args).into(),
135-
},
136-
)
137-
.await;
127+
let mut params = ServeStreamParams {
128+
log: ctx.log,
129+
launcher_paths: ctx.paths,
130+
platform,
131+
requires_auth: true,
132+
exit_barrier: ShutdownRequest::create_rx([ShutdownRequest::CtrlC]),
133+
code_server_args: (&ctx.args).into(),
134+
};
138135

139-
Ok(0)
136+
if !args.on_socket {
137+
serve_stream(tokio::io::stdin(), tokio::io::stderr(), params).await;
138+
return Ok(0);
139+
}
140+
141+
let socket = get_socket_name();
142+
let mut listener = listen_socket_rw_stream(&socket)
143+
.await
144+
.map_err(|e| wrap(e, "error listening on socket"))?;
145+
146+
params
147+
.log
148+
.result(format!("Listening on {}", socket.display()));
149+
150+
let mut servers = FuturesUnordered::new();
151+
152+
loop {
153+
tokio::select! {
154+
Some(_) = servers.next() => {},
155+
socket = listener.accept() => {
156+
match socket {
157+
Ok(s) => {
158+
let (read, write) = socket_stream_split(s);
159+
servers.push(serve_stream(read, write, params.clone()));
160+
},
161+
Err(e) => {
162+
error!(params.log, &format!("Error accepting connection: {}", e));
163+
return Ok(1);
164+
}
165+
}
166+
},
167+
_ = params.exit_barrier.wait() => {
168+
// wait for all servers to finish up:
169+
while (servers.next().await).is_some() { }
170+
return Ok(0);
171+
}
172+
}
173+
}
140174
}
141175

142176
pub async fn service(

cli/src/tunnels/control_server.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ pub async fn serve(
233233
}
234234
}
235235

236+
#[derive(Clone)]
236237
pub struct ServeStreamParams {
237238
pub log: log::Logger,
238239
pub launcher_paths: LauncherPaths,

extensions/markdown-language-features/notebook/index.ts

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -176,42 +176,39 @@ export const activate: ActivationFunction<void> = (ctx) => {
176176
177177
hr {
178178
border: 0;
179-
height: 2px;
180-
border-bottom: 2px solid;
181-
}
182-
183-
h2, h3, h4, h5, h6 {
184-
font-weight: normal;
179+
height: 1px;
180+
border-bottom: 1px solid;
185181
}
186182
187183
h1 {
188-
font-size: 2.3em;
184+
font-size: 2em;
185+
margin-top: 0;
186+
padding-bottom: 0.3em;
187+
border-bottom-width: 1px;
188+
border-bottom-style: solid;
189189
}
190190
191191
h2 {
192-
font-size: 2em;
192+
font-size: 1.5em;
193+
padding-bottom: 0.3em;
194+
border-bottom-width: 1px;
195+
border-bottom-style: solid;
193196
}
194197
195198
h3 {
196-
font-size: 1.7em;
197-
}
198-
199-
h3 {
200-
font-size: 1.5em;
199+
font-size: 1.25em;
201200
}
202201
203202
h4 {
204-
font-size: 1.3em;
203+
font-size: 1em;
205204
}
206205
207206
h5 {
208-
font-size: 1.2em;
207+
font-size: 0.875em;
209208
}
210209
211-
h1,
212-
h2,
213-
h3 {
214-
font-weight: normal;
210+
h6 {
211+
font-size: 0.85em;
215212
}
216213
217214
div {
@@ -229,12 +226,38 @@ export const activate: ActivationFunction<void> = (ctx) => {
229226
}
230227
231228
/* Removes bottom margin when only one item exists in markdown cell */
232-
#preview > *:only-child,
233-
#preview > *:last-child {
229+
#preview > *:not(h1):not(h2):only-child,
230+
#preview > *:not(h1):not(h2):last-child {
234231
margin-bottom: 0;
235232
padding-bottom: 0;
236233
}
237234
235+
h1,
236+
h2,
237+
h3,
238+
h4,
239+
h5,
240+
h6 {
241+
font-weight: 600;
242+
margin-top: 24px;
243+
margin-bottom: 16px;
244+
line-height: 1.25;
245+
}
246+
247+
.vscode-light h1,
248+
.vscode-light h2,
249+
.vscode-light hr,
250+
.vscode-light td {
251+
border-color: rgba(0, 0, 0, 0.18);
252+
}
253+
254+
.vscode-dark h1,
255+
.vscode-dark h2,
256+
.vscode-dark hr,
257+
.vscode-dark td {
258+
border-color: rgba(255, 255, 255, 0.18);
259+
}
260+
238261
/* makes all markdown cells consistent */
239262
div {
240263
min-height: var(--notebook-markdown-min-height);

src/vs/base/common/htmlContent.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export class MarkdownString implements IMarkdownString {
6060
this.value += escapeMarkdownSyntaxTokens(this.supportThemeIcons ? escapeIcons(value) : value)
6161
.replace(/([ \t]+)/g, (_match, g1) => '&nbsp;'.repeat(g1.length))
6262
.replace(/\>/gm, '\\>')
63-
.replace(/\n/g, newlineStyle === MarkdownStringTextNewlineStyle.Break ? '\\\n' : '\n\n');
63+
.replace(/\n/g, newlineStyle === MarkdownStringTextNewlineStyle.Break ? '\\\n' : '\n\n'); // CodeQL [SM02383] The Markdown is fully sanitized after being rendered.
6464

6565
return this;
6666
}

src/vs/base/common/observableImpl/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ export function wasEventTriggeredRecently(event: Event<any>, timeoutMs: number,
278278
return observable;
279279
}
280280

281+
// TODO@hediet: Have `keepCacheAlive` and `recomputeOnChange` instead of forceRecompute
281282
/**
282283
* This ensures the observable is being observed.
283284
* Observed observables (such as {@link derived}s) can maintain a cache, as they receive invalidation events.

0 commit comments

Comments
 (0)