Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
DrHazemAli authored Nov 14, 2024
2 parents 7edfb99 + fd5fa8e commit 33743ef
Show file tree
Hide file tree
Showing 80 changed files with 2,232 additions and 1,607 deletions.
14 changes: 1 addition & 13 deletions cli/src/bin/code/legacy_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::collections::HashMap;

use cli::commands::args::{
CliCore, Commands, DesktopCodeOptions, ExtensionArgs, ExtensionSubcommand,
InstallExtensionArgs, ListExtensionArgs, UninstallExtensionArgs, DownloadExtensionArgs,
InstallExtensionArgs, ListExtensionArgs, UninstallExtensionArgs,
};

/// Tries to parse the argv using the legacy CLI interface, looking for its
Expand Down Expand Up @@ -64,7 +64,6 @@ pub fn try_parse_legacy(
// Now translate them to subcommands.
// --list-extensions -> ext list
// --update-extensions -> update
// --download-extension -> ext download <id>
// --install-extension=id -> ext install <id>
// --uninstall-extension=id -> ext uninstall <id>
// --status -> status
Expand All @@ -80,17 +79,6 @@ pub fn try_parse_legacy(
})),
..Default::default()
})
} else if let Some(exts) = args.get("download-extension") {
Some(CliCore {
subcommand: Some(Commands::Extension(ExtensionArgs {
subcommand: ExtensionSubcommand::Download(DownloadExtensionArgs {
id: exts.to_vec(),
location: get_first_arg_value("location"),
}),
desktop_code_options,
})),
..Default::default()
})
} else if let Some(exts) = args.remove("install-extension") {
Some(CliCore {
subcommand: Some(Commands::Extension(ExtensionArgs {
Expand Down
27 changes: 0 additions & 27 deletions cli/src/commands/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,6 @@ pub enum ExtensionSubcommand {
Uninstall(UninstallExtensionArgs),
/// Update the installed extensions.
Update,
/// Download an extension.
Download(DownloadExtensionArgs),
}

impl ExtensionSubcommand {
Expand Down Expand Up @@ -307,16 +305,6 @@ impl ExtensionSubcommand {
ExtensionSubcommand::Update => {
target.push("--update-extensions".to_string());
}
ExtensionSubcommand::Download(args) => {
for id in args.id.iter() {
target.push(format!("--download-extension={id}"));
}
if let Some(location) = &args.location {
if !location.is_empty() {
target.push(format!("--location={location}"));
}
}
}
}
}
}
Expand Down Expand Up @@ -359,21 +347,6 @@ pub struct UninstallExtensionArgs {
pub id: Vec<String>,
}

#[derive(Args, Debug, Clone)]
pub struct DownloadExtensionArgs {
/// Id of the extension to download. The identifier of an
/// extension is '${publisher}.${name}'. Should provide '--location' to specify the location to download the VSIX.
/// To download a specific version provide '@${version}'.
/// For example: '[email protected]'.
#[clap(name = "ext-id")]
pub id: Vec<String>,

/// Specify the location to download the VSIX.
#[clap(long, value_name = "location")]
pub location: Option<String>,

}

#[derive(Args, Debug, Clone)]
pub struct VersionArgs {
#[clap(subcommand)]
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "code-oss-dev",
"version": "1.96.0",
"distro": "4c96b4c357f6753fff9527bbaf38745be0aee80b",
"distro": "4460d4a3498ebd6eabd7ab5552d3ca2600026f99",
"author": {
"name": "Microsoft Corporation"
},
Expand Down
2 changes: 1 addition & 1 deletion resources/completions/bash/code
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ _@@APPNAME@@()
--list-extensions --show-versions --install-extension
--uninstall-extension --enable-proposed-api --verbose --log -s
--status -p --performance --prof-startup --disable-extensions
--disable-extension --inspect-extensions --update-extensions --download-extension
--disable-extension --inspect-extensions --update-extensions
--inspect-brk-extensions --disable-gpu' -- "$cur") )
[[ $COMPREPLY == *= ]] && compopt -o nospace
return
Expand Down
3 changes: 1 addition & 2 deletions resources/completions/zsh/_code
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,8 @@ arguments=(
'--category[filters installed extension list by category, when using --list-extensions]'
'--show-versions[show versions of installed extensions, when using --list-extensions]'
'--install-extension[install an extension]:id or path:_files -g "*.vsix(-.)"'
'--uninstall-extension[uninstall an extension]:id'
'--uninstall-extension[uninstall an extension]:id or path:_files -g "*.vsix(-.)"'
'--update-extensions[update the installed extensions]'
'--download-extension[download an extension]:id'
'--enable-proposed-api[enables proposed API features for extensions]::extension id: '
'--verbose[print verbose output (implies --wait)]'
'--log[log level to use]:level [info]:(critical error warn info debug trace off)'
Expand Down
60 changes: 55 additions & 5 deletions src/vs/base/browser/cssValue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,16 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Color } from '../common/color.js';
import { FileAccess } from '../common/network.js';
import { URI } from '../common/uri.js';

export type CssFragment = string & { readonly __cssFragment: unique symbol };

function asFragment(raw: string): CssFragment {
return raw as CssFragment;
}

export function asCssValueWithDefault(cssPropertyValue: string | undefined, dflt: string): string {
if (cssPropertyValue !== undefined) {
const variableMatch = cssPropertyValue.match(/^\s*var\((.+)\)$/);
Expand All @@ -20,16 +27,59 @@ export function asCssValueWithDefault(cssPropertyValue: string | undefined, dflt
return dflt;
}

export function asCSSPropertyValue(value: string) {
return `'${value.replace(/'/g, '%27')}'`;
export function value(value: string): CssFragment {
const out = value.replaceAll(/[^_\-a-z0-9]/gi, '');
if (out !== value) {
console.warn(`CSS value ${value} modified to ${out} to be safe for CSS`);
}
return asFragment(out);
}

export function stringValue(value: string): CssFragment {
return asFragment(`'${value.replaceAll(/'/g, '\\000027')}'`);
}

/**
* returns url('...')
*/
export function asCSSUrl(uri: URI | null | undefined): string {
export function asCSSUrl(uri: URI | null | undefined): CssFragment {
if (!uri) {
return `url('')`;
return asFragment(`url('')`);
}
return inline`url(${stringValue(FileAccess.uriToBrowserUri(uri).toString(true))})`;
}

export function className(value: string): CssFragment {
const out = CSS.escape(value);
if (out !== value) {
console.warn(`CSS class name ${value} modified to ${out} to be safe for CSS`);
}
return asFragment(out);
}

type InlineCssTemplateValue = CssFragment | Color;

/**
* Template string tag that that constructs a CSS fragment.
*
* All expressions in the template must be css safe values.
*/
export function inline(strings: TemplateStringsArray, ...values: InlineCssTemplateValue[]): CssFragment {
return asFragment(strings.reduce((result, str, i) => {
const value = values[i] || '';
return result + str + value;
}, ''));
}


export class Builder {
private readonly _parts: CssFragment[] = [];

push(...parts: CssFragment[]): void {
this._parts.push(...parts);
}

join(joiner = '\n'): CssFragment {
return asFragment(this._parts.join(joiner));
}
return `url('${FileAccess.uriToBrowserUri(uri).toString(true).replace(/'/g, '%27')}')`;
}
16 changes: 8 additions & 8 deletions src/vs/base/browser/ui/countBadge/countBadge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { $, append } from '../../dom.js';
import { format } from '../../../common/strings.js';
import './countBadge.css';
import { Disposable, IDisposable, toDisposable } from '../../../common/lifecycle.js';
import { Disposable, IDisposable, MutableDisposable, toDisposable } from '../../../common/lifecycle.js';
import { getBaseLayerHoverDelegate } from '../hover/hoverDelegate2.js';

export interface ICountBadgeOptions {
Expand All @@ -33,7 +33,7 @@ export class CountBadge extends Disposable {
private count: number = 0;
private countFormat: string;
private titleFormat: string;
private hover: IDisposable | undefined;
private readonly hover = this._register(new MutableDisposable<IDisposable>());

constructor(container: HTMLElement, private readonly options: ICountBadgeOptions, private readonly styles: ICountBadgeStyles) {

Expand All @@ -43,6 +43,7 @@ export class CountBadge extends Disposable {
this.countFormat = this.options.countFormat || '{0}';
this.titleFormat = this.options.titleFormat || '';
this.setCount(this.options.count || 0);
this.updateHover();
}

setCount(count: number) {
Expand All @@ -57,14 +58,15 @@ export class CountBadge extends Disposable {

setTitleFormat(titleFormat: string) {
this.titleFormat = titleFormat;
this.updateHover();
this.render();
}

private updateHover(): void {
this.hover?.dispose();
this.hover = undefined;
if (this.titleFormat !== '') {
this.hover = getBaseLayerHoverDelegate().setupDelayedHoverAtMouse(this.element, { content: format(this.titleFormat, this.count), appearance: { compact: true } });
if (this.titleFormat !== '' && !this.hover.value) {
this.hover.value = getBaseLayerHoverDelegate().setupDelayedHoverAtMouse(this.element, () => ({ content: format(this.titleFormat, this.count), appearance: { compact: true } }));
} else if (this.titleFormat === '' && this.hover.value) {
this.hover.value = undefined;
}
}

Expand All @@ -77,7 +79,5 @@ export class CountBadge extends Disposable {
if (this.styles.badgeBorder) {
this.element.style.border = `1px solid ${this.styles.badgeBorder}`;
}

this.updateHover();
}
}
1 change: 0 additions & 1 deletion src/vs/code/node/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ function shouldSpawnCliProcess(argv: NativeParsedArgs): boolean {
return !!argv['install-source']
|| !!argv['list-extensions']
|| !!argv['install-extension']
|| !!argv['download-extension']
|| !!argv['uninstall-extension']
|| !!argv['update-extensions']
|| !!argv['locate-extension']
Expand Down
8 changes: 0 additions & 8 deletions src/vs/code/node/cliProcessMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -282,14 +282,6 @@ class CliMain extends Disposable {
return instantiationService.createInstance(ExtensionManagementCLI, new ConsoleLogger(LogLevel.Info, false)).listExtensions(!!this.argv['show-versions'], this.argv['category'], profileLocation);
}

// Download Extensions
else if (this.argv['download-extension']) {
if (!this.argv['location']) {
throw new Error('The location argument is required to download an extension.');
}
return instantiationService.createInstance(ExtensionManagementCLI, new ConsoleLogger(LogLevel.Info, false)).downloadExtensions(this.argv['download-extension'], URI.parse(this.argv['location']));
}

// Install Extension
else if (this.argv['install-extension'] || this.argv['install-builtin-extension']) {
const installOptions: InstallOptions = { isMachineScoped: !!this.argv['do-not-sync'], installPreReleaseVersion: !!this.argv['pre-release'], profileLocation };
Expand Down
2 changes: 2 additions & 0 deletions src/vs/editor/browser/controller/mouseHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,13 @@ import { ViewEventHandler } from '../../common/viewEventHandler.js';
import { EditorOption } from '../../common/config/editorOptions.js';
import { NavigationCommandRevealType } from '../coreCommands.js';
import { MouseWheelClassifier } from '../../../base/browser/ui/scrollbar/scrollableElement.js';
import type { ViewLinesGpu } from '../viewParts/viewLinesGpu/viewLinesGpu.js';

export interface IPointerHandlerHelper {
viewDomNode: HTMLElement;
linesContentDomNode: HTMLElement;
viewLinesDomNode: HTMLElement;
viewLinesGpu: ViewLinesGpu | undefined;

focusTextArea(): void;
dispatchTextAreaEvent(event: CustomEvent): void;
Expand Down
29 changes: 29 additions & 0 deletions src/vs/editor/browser/controller/mouseTarget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { PositionAffinity } from '../../common/model.js';
import { InjectedText } from '../../common/modelLineProjectionData.js';
import { Mutable } from '../../../base/common/types.js';
import { Lazy } from '../../../base/common/lazy.js';
import type { ViewLinesGpu } from '../viewParts/viewLinesGpu/viewLinesGpu.js';

const enum HitTestResultType {
Unknown,
Expand Down Expand Up @@ -238,6 +239,7 @@ export class HitTestContext {
public readonly viewModel: IViewModel;
public readonly layoutInfo: EditorLayoutInfo;
public readonly viewDomNode: HTMLElement;
public readonly viewLinesGpu: ViewLinesGpu | undefined;
public readonly lineHeight: number;
public readonly stickyTabStops: boolean;
public readonly typicalHalfwidthCharacterWidth: number;
Expand All @@ -251,6 +253,7 @@ export class HitTestContext {
const options = context.configuration.options;
this.layoutInfo = options.get(EditorOption.layoutInfo);
this.viewDomNode = viewHelper.viewDomNode;
this.viewLinesGpu = viewHelper.viewLinesGpu;
this.lineHeight = options.get(EditorOption.lineHeight);
this.stickyTabStops = options.get(EditorOption.stickyTabStops);
this.typicalHalfwidthCharacterWidth = options.get(EditorOption.fontInfo).typicalHalfwidthCharacterWidth;
Expand Down Expand Up @@ -754,6 +757,32 @@ export class MouseTargetFactory {
const pos = new Position(lineNumber, ctx.viewModel.getLineMaxColumn(lineNumber));
return request.fulfillContentEmpty(pos, detail);
}
} else {
if (ctx.viewLinesGpu) {
const lineNumber = ctx.getLineNumberAtVerticalOffset(request.mouseVerticalOffset);
if (ctx.viewModel.getLineLength(lineNumber) === 0) {
const lineWidth = ctx.getLineWidth(lineNumber);
const detail = createEmptyContentDataInLines(request.mouseContentHorizontalOffset - lineWidth);
return request.fulfillContentEmpty(new Position(lineNumber, 1), detail);
}

const lineWidth = ctx.getLineWidth(lineNumber);
if (request.mouseContentHorizontalOffset >= lineWidth) {
// TODO: This is wrong for RTL
const detail = createEmptyContentDataInLines(request.mouseContentHorizontalOffset - lineWidth);
const pos = new Position(lineNumber, ctx.viewModel.getLineMaxColumn(lineNumber));
return request.fulfillContentEmpty(pos, detail);
}

const position = ctx.viewLinesGpu.getPositionAtCoordinate(lineNumber, request.mouseContentHorizontalOffset);
if (position) {
const detail: IMouseTargetContentTextData = {
injectedText: null,
mightBeForeignElement: false
};
return request.fulfillContentText(position, EditorRange.fromPositions(position, position), detail);
}
}
}

// Do the hit test (if not already done)
Expand Down
Loading

0 comments on commit 33743ef

Please sign in to comment.