Skip to content
This repository has been archived by the owner on Feb 25, 2025. It is now read-only.

Commit

Permalink
Merge pull request #581 from codestoryai/fetch-upstream-160424
Browse files Browse the repository at this point in the history
Fetch upstream 160424
  • Loading branch information
ghostwriternr authored Apr 16, 2024
2 parents c93741b + 0fcb54d commit 09eaeb1
Show file tree
Hide file tree
Showing 30 changed files with 305 additions and 185 deletions.
3 changes: 1 addition & 2 deletions build/lib/stylelint/validateVariableNames.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions build/lib/stylelint/validateVariableNames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ function getKnownVariableNames() {
return knownVariables;
}

const iconVariable = /^--vscode-icon-.+-(content|font-family)$/;

export interface IValidator {
(value: string, report: (message: string) => void): void;
}
Expand All @@ -31,7 +29,7 @@ export function getVariableNameValidator(): IValidator {
let match;
while (match = RE_VAR_PROP.exec(value)) {
const variableName = match[1];
if (variableName && !allVariables.has(variableName) && !iconVariable.test(variableName)) {
if (variableName && !allVariables.has(variableName)) {
report(variableName);
}
}
Expand Down
4 changes: 2 additions & 2 deletions cli/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cli/src/tunnels/service_macos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl ServiceManager for LaunchdService {
match capture_command_and_check_status("launchctl", &["stop", &get_service_label()]).await {
Ok(_) => {}
// status 3 == "no such process"
Err(CodeError::CommandFailed { code, .. }) if code == 3 => {}
Err(CodeError::CommandFailed { code: 3, .. }) => {}
Err(e) => return Err(wrap(e, "error stopping service").into()),
};

Expand Down
2 changes: 1 addition & 1 deletion extensions/markdown-language-features/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@
]
},
"markdown.editor.filePaste.enabled": {
"type": "boolean",
"type": "string",
"scope": "resource",
"markdownDescription": "%configuration.markdown.editor.filePaste.enabled%",
"default": "smart",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,30 +18,26 @@ import { conditionalRegistration, requireMinVersion, requireSomeCapability } fro


interface OrganizeImportsCommandMetadata {
readonly ids: readonly string[];
readonly title: string;
readonly minVersion?: API;
readonly kind: vscode.CodeActionKind;
readonly mode: OrganizeImportsMode;
}

const organizeImportsCommand: OrganizeImportsCommandMetadata = {
ids: ['typescript.organizeImports'],
title: vscode.l10n.t("Organize Imports"),
kind: vscode.CodeActionKind.SourceOrganizeImports,
mode: OrganizeImportsMode.All,
};

const sortImportsCommand: OrganizeImportsCommandMetadata = {
ids: ['typescript.sortImports', 'javascript.sortImports'],
minVersion: API.v430,
title: vscode.l10n.t("Sort Imports"),
kind: vscode.CodeActionKind.Source.append('sortImports'),
mode: OrganizeImportsMode.SortAndCombine,
};

const removeUnusedImportsCommand: OrganizeImportsCommandMetadata = {
ids: ['typescript.removeUnusedImports', 'javascript.removeUnusedImports'],
minVersion: API.v490,
title: vscode.l10n.t("Remove Unused Imports"),
kind: vscode.CodeActionKind.Source.append('removeUnusedImports'),
Expand All @@ -50,14 +46,14 @@ const removeUnusedImportsCommand: OrganizeImportsCommandMetadata = {

class OrganizeImportsCommand implements Command {

public static readonly ID = '_typescript.organizeImports';
public readonly id = OrganizeImportsCommand.ID;

constructor(
public readonly id: string,
private readonly commandMetadata: OrganizeImportsCommandMetadata,
private readonly client: ITypeScriptServiceClient,
private readonly telemetryReporter: TelemetryReporter,
) { }

public async execute(file?: string): Promise<any> {
public async execute(): Promise<any> {
/* __GDPR__
"organizeImports.execute" : {
"owner": "mjbvz",
Expand All @@ -67,48 +63,20 @@ class OrganizeImportsCommand implements Command {
}
*/
this.telemetryReporter.logTelemetry('organizeImports.execute', {});
if (!file) {
const activeEditor = vscode.window.activeTextEditor;
if (!activeEditor) {
vscode.window.showErrorMessage(vscode.l10n.t("Organize Imports failed. No resource provided."));
return;
}

const resource = activeEditor.document.uri;
const document = await vscode.workspace.openTextDocument(resource);
const openedFiledPath = this.client.toOpenTsFilePath(document);
if (!openedFiledPath) {
vscode.window.showErrorMessage(vscode.l10n.t("Organize Imports failed. Unknown file type."));
return;
}

file = openedFiledPath;
}

const args: Proto.OrganizeImportsRequestArgs = {
scope: {
type: 'file',
args: {
file
}
},
// Deprecated in 4.9; `mode` takes priority
skipDestructiveCodeActions: this.commandMetadata.mode === OrganizeImportsMode.SortAndCombine,
mode: typeConverters.OrganizeImportsMode.toProtocolOrganizeImportsMode(this.commandMetadata.mode),
};
const response = await this.client.interruptGetErr(() => this.client.execute('organizeImports', args, nulToken));
if (response.type !== 'response' || !response.body) {
return;
}
}
}

if (response.body.length) {
const edits = typeConverters.WorkspaceEdit.fromFileCodeEdits(this.client, response.body);
return vscode.workspace.applyEdit(edits);
}
class ImportCodeAction extends vscode.CodeAction {
constructor(
title: string,
kind: vscode.CodeActionKind,
public readonly document: vscode.TextDocument,
) {
super(title, kind);
}
}

class ImportsCodeActionProvider implements vscode.CodeActionProvider {
class ImportsCodeActionProvider implements vscode.CodeActionProvider<ImportCodeAction> {

constructor(
private readonly client: ITypeScriptServiceClient,
Expand All @@ -117,31 +85,62 @@ class ImportsCodeActionProvider implements vscode.CodeActionProvider {
private readonly fileConfigManager: FileConfigurationManager,
telemetryReporter: TelemetryReporter,
) {
for (const id of commandMetadata.ids) {
commandManager.register(new OrganizeImportsCommand(id, commandMetadata, client, telemetryReporter));
}
commandManager.register(new OrganizeImportsCommand(telemetryReporter));
}

public provideCodeActions(
document: vscode.TextDocument,
_range: vscode.Range,
context: vscode.CodeActionContext,
token: vscode.CancellationToken
): vscode.CodeAction[] {
_token: vscode.CancellationToken
): ImportCodeAction[] {
if (!context.only?.contains(this.commandMetadata.kind)) {
return [];
}

const file = this.client.toOpenTsFilePath(document);
if (!file) {
return [];
}

if (!context.only?.contains(this.commandMetadata.kind)) {
return [];
return [new ImportCodeAction(this.commandMetadata.title, this.commandMetadata.kind, document)];
}

async resolveCodeAction(codeAction: ImportCodeAction, token: vscode.CancellationToken): Promise<ImportCodeAction | undefined> {
const response = await this.client.interruptGetErr(async () => {
await this.fileConfigManager.ensureConfigurationForDocument(codeAction.document, token);
if (token.isCancellationRequested) {
return;
}

const file = this.client.toOpenTsFilePath(codeAction.document);
if (!file) {
return;
}

const args: Proto.OrganizeImportsRequestArgs = {
scope: {
type: 'file',
args: { file }
},
// Deprecated in 4.9; `mode` takes priority
skipDestructiveCodeActions: this.commandMetadata.mode === OrganizeImportsMode.SortAndCombine,
mode: typeConverters.OrganizeImportsMode.toProtocolOrganizeImportsMode(this.commandMetadata.mode),
};

return this.client.execute('organizeImports', args, nulToken);
});
if (response?.type !== 'response' || !response.body || token.isCancellationRequested) {
return;
}

if (response.body.length) {
codeAction.edit = typeConverters.WorkspaceEdit.fromFileCodeEdits(this.client, response.body);
}

this.fileConfigManager.ensureConfigurationForDocument(document, token);
codeAction.command = { command: OrganizeImportsCommand.ID, title: '', arguments: [] };

const action = new vscode.CodeAction(this.commandMetadata.title, this.commandMetadata.kind);
action.command = { title: '', command: this.commandMetadata.ids[0], arguments: [file] };
return [action];
return codeAction;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/vs/base/browser/ui/codicons/codicon/codicon.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
src: url("./codicon.ttf?5d4d76ab2ce5108968ad644d591a16a6") format("truetype");
}

.codicon {
.codicon[class*='codicon-'] {
font: normal normal normal 16px/1 codicon;
display: inline-block;
text-decoration: none;
Expand Down
3 changes: 1 addition & 2 deletions src/vs/base/browser/ui/menu/menubar.css
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,7 @@

.menubar:not(.compact) .menubar-menu-button:first-child .toolbar-toggle-more::before,
.menubar.compact .toolbar-toggle-more::before {
content: var(--vscode-icon-menu-content) !important;
font-family: var(--vscode-icon-menu-font-family) !important;
content: "\eb94" !important;
}

/* Match behavior of outline for activity bar icons */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,5 @@
}

.inline-progress-widget:hover .icon::before {
content: var(--vscode-icon-x-content);
font-family: var(--vscode-icon-x-font-family);
content: "\ea76"; /* codicon-x */
}
33 changes: 13 additions & 20 deletions src/vs/platform/theme/browser/iconsStyleSheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,34 @@ export function getIconsStyleSheet(themeService: IThemeService | undefined): IIc
getCSS() {
const productIconTheme = themeService ? themeService.getProductIconTheme() : new UnthemedProductIconTheme();
const usedFontIds: { [id: string]: IconFontDefinition } = {};

const rules: string[] = [];
const rootAttribs: string[] = [];
for (const contribution of iconRegistry.getIcons()) {
const formatIconRule = (contribution: IconContribution): string | undefined => {
const definition = productIconTheme.getIcon(contribution);
if (!definition) {
continue;
return undefined;
}

const fontContribution = definition.font;
const fontFamilyVar = `--vscode-icon-${contribution.id}-font-family`;
const contentVar = `--vscode-icon-${contribution.id}-content`;
if (fontContribution) {
usedFontIds[fontContribution.id] = fontContribution.definition;
rootAttribs.push(
`${fontFamilyVar}: ${asCSSPropertyValue(fontContribution.id)};`,
`${contentVar}: '${definition.fontCharacter}';`,
);
rules.push(`.codicon-${contribution.id}:before { content: '${definition.fontCharacter}'; font-family: ${asCSSPropertyValue(fontContribution.id)}; }`);
} else {
rootAttribs.push(`${contentVar}: '${definition.fontCharacter}'; ${fontFamilyVar}: 'codicon';`);
rules.push(`.codicon-${contribution.id}:before { content: '${definition.fontCharacter}'; }`);
return `.codicon-${contribution.id}:before { content: '${definition.fontCharacter}'; font-family: ${asCSSPropertyValue(fontContribution.id)}; }`;
}
}
// default font (codicon)
return `.codicon-${contribution.id}:before { content: '${definition.fontCharacter}'; }`;
};

const rules = [];
for (const contribution of iconRegistry.getIcons()) {
const rule = formatIconRule(contribution);
if (rule) {
rules.push(rule);
}
}
for (const id in usedFontIds) {
const definition = usedFontIds[id];
const fontWeight = definition.weight ? `font-weight: ${definition.weight};` : '';
const fontStyle = definition.style ? `font-style: ${definition.style};` : '';
const src = definition.src.map(l => `${asCSSUrl(l.location)} format('${l.format}')`).join(', ');
rules.push(`@font-face { src: ${src}; font-family: ${asCSSPropertyValue(id)};${fontWeight}${fontStyle} font-display: block; }`);
}

rules.push(`:root { ${rootAttribs.join(' ')} }`);

return rules.join('\n');
}
};
Expand Down
9 changes: 0 additions & 9 deletions src/vs/platform/workspace/common/workspaceTrust.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,13 @@
import { Event } from 'vs/base/common/event';
import { IDisposable } from 'vs/base/common/lifecycle';
import { URI } from 'vs/base/common/uri';
import { localize } from 'vs/nls';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';

export enum WorkspaceTrustScope {
Local = 0,
Remote = 1
}

export function workspaceTrustToString(trustState: boolean) {
if (trustState) {
return localize('trusted', "Trusted");
} else {
return localize('untrusted', "Restricted Mode");
}
}

export interface WorkspaceTrustRequestButton {
readonly label: string;
readonly type: 'ContinueWithTrust' | 'ContinueWithoutTrust' | 'Manage' | 'Cancel';
Expand Down
4 changes: 1 addition & 3 deletions src/vs/workbench/browser/actions/media/actions.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
*--------------------------------------------------------------------------------------------*/

.monaco-workbench .quick-input-list .quick-input-list-entry.has-actions:hover .quick-input-list-entry-action-bar .action-label.dirty-workspace::before {
/* Close icon flips between black dot and "X" for dirty workspaces */
content: var(--vscode-icon-x-content);
font-family: var(--vscode-icon-x-font-family);
content: "\ea76"; /* Close icon flips between black dot and "X" for dirty workspaces */
}

.monaco-workbench .screencast-mouse {
Expand Down
3 changes: 1 addition & 2 deletions src/vs/workbench/browser/media/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,7 @@ body.web {
}

.monaco-workbench .select-container:after {
content: var(--vscode-icon-chevron-down-content);
font-family: var(--vscode-icon-chevron-down-font-family);
content: "\eab4";
font-family: codicon;
font-size: 16px;
width: 16px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,5 @@
*--------------------------------------------------------------------------------------------*/

.quick-input-list .quick-input-list-entry.has-actions:hover .quick-input-list-entry-action-bar .action-label.dirty-editor::before {
/* Close icon flips between black dot and "X" for dirty open editors */
content: var(--vscode-icon-x-content);
font-family: var(--vscode-icon-x-font-family);
content: "\ea76"; /* Close icon flips between black dot and "X" for dirty open editors */
}
Loading

0 comments on commit 09eaeb1

Please sign in to comment.