Skip to content

Commit

Permalink
Rebase against the upstream c85bf61
Browse files Browse the repository at this point in the history
vscode-upstream-sha1: c85bf61
  • Loading branch information
Eclipse Che Sync committed Jul 19, 2023
2 parents ff67a08 + c85bf61 commit 25ed5fa
Show file tree
Hide file tree
Showing 120 changed files with 3,024 additions and 1,511 deletions.
4 changes: 3 additions & 1 deletion code/cli/src/bin/code/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ async fn main() -> Result<(), std::convert::Infallible> {
args::VersionSubcommand::Show => version::show(context!()).await,
},

Some(args::Commands::CommandShell) => tunnels::command_shell(context!()).await,
Some(args::Commands::CommandShell(cs_args)) => {
tunnels::command_shell(context!(), cs_args).await
}

Some(args::Commands::Tunnel(tunnel_args)) => match tunnel_args.subcommand {
Some(args::TunnelSubcommand::Prune) => tunnels::prune(context!()).await,
Expand Down
9 changes: 8 additions & 1 deletion code/cli/src/commands/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,14 @@ pub enum Commands {

/// Runs the control server on process stdin/stdout
#[clap(hide = true)]
CommandShell,
CommandShell(CommandShellArgs),
}

#[derive(Args, Debug, Clone)]
pub struct CommandShellArgs {
/// Listen on a socket instead of stdin/stdout.
#[clap(long)]
pub on_socket: bool,
}

#[derive(Args, Debug, Clone)]
Expand Down
68 changes: 51 additions & 17 deletions code/cli/src/commands/tunnels.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@

use async_trait::async_trait;
use base64::{engine::general_purpose as b64, Engine as _};
use futures::{stream::FuturesUnordered, StreamExt};
use serde::Serialize;
use sha2::{Digest, Sha256};
use std::{str::FromStr, time::Duration};
use sysinfo::Pid;

use super::{
args::{
AuthProvider, CliCore, ExistingTunnelArgs, TunnelRenameArgs, TunnelServeArgs,
TunnelServiceSubCommands, TunnelUserSubCommands,
AuthProvider, CliCore, CommandShellArgs, ExistingTunnelArgs, TunnelRenameArgs,
TunnelServeArgs, TunnelServiceSubCommands, TunnelUserSubCommands,
},
CommandContext,
};

use crate::{
async_pipe::{get_socket_name, listen_socket_rw_stream, socket_stream_split},
auth::Auth,
constants::{APPLICATION_NAME, TUNNEL_CLI_LOCK_NAME, TUNNEL_SERVICE_LOCK_NAME},
log,
Expand Down Expand Up @@ -120,23 +122,55 @@ impl ServiceContainer for TunnelServiceContainer {
}
}

pub async fn command_shell(ctx: CommandContext) -> Result<i32, AnyError> {
pub async fn command_shell(ctx: CommandContext, args: CommandShellArgs) -> Result<i32, AnyError> {
let platform = PreReqChecker::new().verify().await?;
serve_stream(
tokio::io::stdin(),
tokio::io::stderr(),
ServeStreamParams {
log: ctx.log,
launcher_paths: ctx.paths,
platform,
requires_auth: true,
exit_barrier: ShutdownRequest::create_rx([ShutdownRequest::CtrlC]),
code_server_args: (&ctx.args).into(),
},
)
.await;
let mut params = ServeStreamParams {
log: ctx.log,
launcher_paths: ctx.paths,
platform,
requires_auth: true,
exit_barrier: ShutdownRequest::create_rx([ShutdownRequest::CtrlC]),
code_server_args: (&ctx.args).into(),
};

Ok(0)
if !args.on_socket {
serve_stream(tokio::io::stdin(), tokio::io::stderr(), params).await;
return Ok(0);
}

let socket = get_socket_name();
let mut listener = listen_socket_rw_stream(&socket)
.await
.map_err(|e| wrap(e, "error listening on socket"))?;

params
.log
.result(format!("Listening on {}", socket.display()));

let mut servers = FuturesUnordered::new();

loop {
tokio::select! {
Some(_) = servers.next() => {},
socket = listener.accept() => {
match socket {
Ok(s) => {
let (read, write) = socket_stream_split(s);
servers.push(serve_stream(read, write, params.clone()));
},
Err(e) => {
error!(params.log, &format!("Error accepting connection: {}", e));
return Ok(1);
}
}
},
_ = params.exit_barrier.wait() => {
// wait for all servers to finish up:
while (servers.next().await).is_some() { }
return Ok(0);
}
}
}
}

pub async fn service(
Expand Down
1 change: 1 addition & 0 deletions code/cli/src/tunnels/control_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ pub async fn serve(
}
}

#[derive(Clone)]
pub struct ServeStreamParams {
pub log: log::Logger,
pub launcher_paths: LauncherPaths,
Expand Down
2 changes: 2 additions & 0 deletions code/extensions/github/src/links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ export function getVscodeDevHost(): string {
}

export async function ensurePublished(repository: Repository, file: vscode.Uri) {
await repository.status();

if ((repository.state.HEAD?.type === RefType.Head || repository.state.HEAD?.type === RefType.Tag)
// If HEAD is not published, make sure it is
&& !repository?.state.HEAD?.upstream
Expand Down
65 changes: 44 additions & 21 deletions code/extensions/markdown-language-features/notebook/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,42 +176,39 @@ export const activate: ActivationFunction<void> = (ctx) => {
hr {
border: 0;
height: 2px;
border-bottom: 2px solid;
}
h2, h3, h4, h5, h6 {
font-weight: normal;
height: 1px;
border-bottom: 1px solid;
}
h1 {
font-size: 2.3em;
font-size: 2em;
margin-top: 0;
padding-bottom: 0.3em;
border-bottom-width: 1px;
border-bottom-style: solid;
}
h2 {
font-size: 2em;
font-size: 1.5em;
padding-bottom: 0.3em;
border-bottom-width: 1px;
border-bottom-style: solid;
}
h3 {
font-size: 1.7em;
}
h3 {
font-size: 1.5em;
font-size: 1.25em;
}
h4 {
font-size: 1.3em;
font-size: 1em;
}
h5 {
font-size: 1.2em;
font-size: 0.875em;
}
h1,
h2,
h3 {
font-weight: normal;
h6 {
font-size: 0.85em;
}
div {
Expand All @@ -229,12 +226,38 @@ export const activate: ActivationFunction<void> = (ctx) => {
}
/* Removes bottom margin when only one item exists in markdown cell */
#preview > *:only-child,
#preview > *:last-child {
#preview > *:not(h1):not(h2):only-child,
#preview > *:not(h1):not(h2):last-child {
margin-bottom: 0;
padding-bottom: 0;
}
h1,
h2,
h3,
h4,
h5,
h6 {
font-weight: 600;
margin-top: 24px;
margin-bottom: 16px;
line-height: 1.25;
}
.vscode-light h1,
.vscode-light h2,
.vscode-light hr,
.vscode-light td {
border-color: rgba(0, 0, 0, 0.18);
}
.vscode-dark h1,
.vscode-dark h2,
.vscode-dark hr,
.vscode-dark td {
border-color: rgba(255, 255, 255, 0.18);
}
/* makes all markdown cells consistent */
div {
min-height: var(--notebook-markdown-min-height);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export class MarkdownItEngine implements IMdParser {
_contributionProvider.onContributionsChanged(() => {
// Markdown plugin contributions may have changed
this._md = undefined;
this._tokenCache.clean();
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class MarkdownPreview extends Disposable implements WebviewResourceProvider {
}

this._register(_contributionProvider.onContributionsChanged(() => {
setTimeout(() => this.refresh(), 0);
setTimeout(() => this.refresh(true), 0);
}));

this._register(vscode.workspace.onDidChangeTextDocument(event => {
Expand Down
31 changes: 11 additions & 20 deletions code/extensions/notebook-renderers/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
*--------------------------------------------------------------------------------------------*/

import type { ActivationFunction, OutputItem, RendererContext } from 'vscode-notebook-renderer';
import { createOutputContent, scrollableClass } from './textHelper';
import { HtmlRenderingHook, IDisposable, IRichRenderContext, JavaScriptRenderingHook, RenderOptions } from './rendererTypes';
import { createOutputContent, appendOutput, scrollableClass } from './textHelper';
import { HtmlRenderingHook, IDisposable, IRichRenderContext, JavaScriptRenderingHook, OutputWithAppend, RenderOptions } from './rendererTypes';
import { ttPolicy } from './htmlHelper';

function clearContainer(container: HTMLElement) {
Expand Down Expand Up @@ -152,7 +152,7 @@ function renderError(
outputInfo: OutputItem,
outputElement: HTMLElement,
ctx: IRichRenderContext,
trustHTML: boolean
trustHtml: boolean
): IDisposable {
const disposableStore = createDisposableStore();

Expand All @@ -172,7 +172,7 @@ function renderError(
outputElement.classList.add('traceback');

const outputScrolling = scrollingEnabled(outputInfo, ctx.settings);
const content = createOutputContent(outputInfo.id, [err.stack ?? ''], ctx.settings.lineLimit, outputScrolling, trustHTML);
const content = createOutputContent(outputInfo.id, err.stack ?? '', { linesLimit: ctx.settings.lineLimit, scrollable: outputScrolling, trustHtml });
const contentParent = document.createElement('div');
contentParent.classList.toggle('word-wrap', ctx.settings.outputWordWrap);
disposableStore.push(ctx.onDidChangeSettings(e => {
Expand Down Expand Up @@ -270,29 +270,23 @@ function scrollingEnabled(output: OutputItem, options: RenderOptions) {
// div.output.output-stream <-- outputElement parameter
// div.scrollable? tabindex="0" <-- contentParent
// div output-item-id="{guid}" <-- content from outputItem parameter
function renderStream(outputInfo: OutputItem, outputElement: HTMLElement, error: boolean, ctx: IRichRenderContext): IDisposable {
function renderStream(outputInfo: OutputWithAppend, outputElement: HTMLElement, error: boolean, ctx: IRichRenderContext): IDisposable {
const disposableStore = createDisposableStore();
const outputScrolling = scrollingEnabled(outputInfo, ctx.settings);
const outputOptions = { linesLimit: ctx.settings.lineLimit, scrollable: outputScrolling, trustHtml: false, error };

outputElement.classList.add('output-stream');

const text = outputInfo.text();
const newContent = createOutputContent(outputInfo.id, [text], ctx.settings.lineLimit, outputScrolling, false);
newContent.setAttribute('output-item-id', outputInfo.id);
if (error) {
newContent.classList.add('error');
}

const scrollTop = outputScrolling ? findScrolledHeight(outputElement) : undefined;

const previousOutputParent = getPreviousMatchingContentGroup(outputElement);
// If the previous output item for the same cell was also a stream, append this output to the previous
if (previousOutputParent) {
const existingContent = previousOutputParent.querySelector(`[output-item-id="${outputInfo.id}"]`) as HTMLElement | null;
if (existingContent) {
existingContent.replaceWith(newContent);

appendOutput(outputInfo, existingContent, outputOptions);
} else {
const newContent = createOutputContent(outputInfo.id, outputInfo.text(), outputOptions);
previousOutputParent.appendChild(newContent);
}
previousOutputParent.classList.toggle('scrollbar-visible', previousOutputParent.scrollHeight > previousOutputParent.clientHeight);
Expand All @@ -301,12 +295,9 @@ function renderStream(outputInfo: OutputItem, outputElement: HTMLElement, error:
const existingContent = outputElement.querySelector(`[output-item-id="${outputInfo.id}"]`) as HTMLElement | null;
let contentParent = existingContent?.parentElement;
if (existingContent && contentParent) {
existingContent.replaceWith(newContent);
while (newContent.nextSibling) {
// clear out any stale content if we had previously combined streaming outputs into this one
newContent.nextSibling.remove();
}
appendOutput(outputInfo, existingContent, outputOptions);
} else {
const newContent = createOutputContent(outputInfo.id, outputInfo.text(), outputOptions);
contentParent = document.createElement('div');
contentParent.appendChild(newContent);
while (outputElement.firstChild) {
Expand All @@ -333,7 +324,7 @@ function renderText(outputInfo: OutputItem, outputElement: HTMLElement, ctx: IRi

const text = outputInfo.text();
const outputScrolling = scrollingEnabled(outputInfo, ctx.settings);
const content = createOutputContent(outputInfo.id, [text], ctx.settings.lineLimit, outputScrolling, false);
const content = createOutputContent(outputInfo.id, text, { linesLimit: ctx.settings.lineLimit, scrollable: outputScrolling, trustHtml: false });
content.classList.add('output-plaintext');
if (ctx.settings.outputWordWrap) {
content.classList.add('word-wrap');
Expand Down
11 changes: 11 additions & 0 deletions code/extensions/notebook-renderers/src/rendererTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,14 @@ export interface RenderOptions {
}

export type IRichRenderContext = RendererContext<void> & { readonly settings: RenderOptions; readonly onDidChangeSettings: Event<RenderOptions> };

export type OutputElementOptions = {
linesLimit: number;
scrollable?: boolean;
error?: boolean;
trustHtml?: boolean;
};

export interface OutputWithAppend extends OutputItem {
appendedText?(): string | undefined;
}
Loading

0 comments on commit 25ed5fa

Please sign in to comment.