Skip to content

Commit

Permalink
Merge from vscode 7779310 (#9220)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony Dresser authored Feb 20, 2020
1 parent ab6fb81 commit 0cec223
Show file tree
Hide file tree
Showing 115 changed files with 1,429 additions and 1,131 deletions.
33 changes: 3 additions & 30 deletions extensions/configuration-editing/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getLocation, parse, visit } from 'jsonc-parser';
import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
import { SettingsDocument } from './settingsDocumentHelper';
import { provideInstalledExtensionProposals } from './extensionsProposals';
const localize = nls.loadMessageBundle();

export function activate(context: vscode.ExtensionContext): void {
Expand Down Expand Up @@ -80,7 +81,7 @@ function registerExtensionsCompletionsInExtensionsDocument(): vscode.Disposable
const range = document.getWordRangeAtPosition(position) || new vscode.Range(position, position);
if (location.path[0] === 'recommendations') {
const extensionsContent = <IExtensionsContent>parse(document.getText());
return provideInstalledExtensionProposals(extensionsContent, range);
return provideInstalledExtensionProposals(extensionsContent && extensionsContent.recommendations || [], range, false);
}
return [];
}
Expand All @@ -94,41 +95,13 @@ function registerExtensionsCompletionsInWorkspaceConfigurationDocument(): vscode
const range = document.getWordRangeAtPosition(position) || new vscode.Range(position, position);
if (location.path[0] === 'extensions' && location.path[1] === 'recommendations') {
const extensionsContent = <IExtensionsContent>parse(document.getText())['extensions'];
return provideInstalledExtensionProposals(extensionsContent, range);
return provideInstalledExtensionProposals(extensionsContent && extensionsContent.recommendations || [], range, false);
}
return [];
}
});
}

function provideInstalledExtensionProposals(extensionsContent: IExtensionsContent, range: vscode.Range): vscode.ProviderResult<vscode.CompletionItem[] | vscode.CompletionList> {
const alreadyEnteredExtensions = extensionsContent && extensionsContent.recommendations || [];
if (Array.isArray(alreadyEnteredExtensions)) {
const knownExtensionProposals = vscode.extensions.all.filter(e =>
!(e.id.startsWith('vscode.')
|| e.id === 'Microsoft.vscode-markdown'
|| alreadyEnteredExtensions.indexOf(e.id) > -1));
if (knownExtensionProposals.length) {
return knownExtensionProposals.map(e => {
const item = new vscode.CompletionItem(e.id);
const insertText = `"${e.id}"`;
item.kind = vscode.CompletionItemKind.Value;
item.insertText = insertText;
item.range = range;
item.filterText = insertText;
return item;
});
} else {
const example = new vscode.CompletionItem(localize('exampleExtension', "Example"));
example.insertText = '"vscode.csharp"';
example.kind = vscode.CompletionItemKind.Value;
example.range = range;
return [example];
}
}
return undefined;
}

vscode.languages.registerDocumentSymbolProvider({ pattern: '**/launch.json', language: 'jsonc' }, {
provideDocumentSymbols(document: vscode.TextDocument, _token: vscode.CancellationToken): vscode.ProviderResult<vscode.SymbolInformation[]> {
const result: vscode.SymbolInformation[] = [];
Expand Down
35 changes: 35 additions & 0 deletions extensions/configuration-editing/src/extensionsProposals.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import * as vscode from 'vscode';
import * as nls from 'vscode-nls';
const localize = nls.loadMessageBundle();


export function provideInstalledExtensionProposals(existing: string[], range: vscode.Range, includeBuiltinExtensions: boolean): vscode.ProviderResult<vscode.CompletionItem[] | vscode.CompletionList> {
if (Array.isArray(existing)) {
const extensions = includeBuiltinExtensions ? vscode.extensions.all : vscode.extensions.all.filter(e => !(e.id.startsWith('vscode.') || e.id === 'Microsoft.vscode-markdown'));
const knownExtensionProposals = extensions.filter(e => existing.indexOf(e.id) === -1);
if (knownExtensionProposals.length) {
return knownExtensionProposals.map(e => {
const item = new vscode.CompletionItem(e.id);
const insertText = `"${e.id}"`;
item.kind = vscode.CompletionItemKind.Value;
item.insertText = insertText;
item.range = range;
item.filterText = insertText;
return item;
});
} else {
const example = new vscode.CompletionItem(localize('exampleExtension', "Example"));
example.insertText = '"vscode.csharp"';
example.kind = vscode.CompletionItemKind.Value;
example.range = range;
return [example];
}
}
return undefined;
}

14 changes: 12 additions & 2 deletions extensions/configuration-editing/src/settingsDocumentHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
*--------------------------------------------------------------------------------------------*/

import * as vscode from 'vscode';
import { getLocation, Location } from 'jsonc-parser';
import { getLocation, Location, parse } from 'jsonc-parser';
import * as nls from 'vscode-nls';
import { provideInstalledExtensionProposals } from './extensionsProposals';

const localize = nls.loadMessageBundle();

export class SettingsDocument {

constructor(private document: vscode.TextDocument) { }

public provideCompletionItems(position: vscode.Position, _token: vscode.CancellationToken): vscode.ProviderResult<vscode.CompletionItem[]> {
public provideCompletionItems(position: vscode.Position, _token: vscode.CancellationToken): vscode.ProviderResult<vscode.CompletionItem[] | vscode.CompletionList> {
const location = getLocation(this.document.getText(), this.document.offsetAt(position));
const range = this.document.getWordRangeAtPosition(position) || new vscode.Range(position, position);

Expand Down Expand Up @@ -41,6 +42,15 @@ export class SettingsDocument {
});
}

// sync.ignoredExtensions
if (location.path[0] === 'sync.ignoredExtensions') {
let ignoredExtensions = [];
try {
ignoredExtensions = parse(this.document.getText())['sync.ignoredExtensions'];
} catch (e) {/* ignore error */ }
return provideInstalledExtensionProposals(ignoredExtensions, range, true);
}

return this.provideLanguageOverridesCompletionItems(location, position);
}

Expand Down
11 changes: 10 additions & 1 deletion extensions/git/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1847,7 +1847,16 @@
{
"view": "workbench.scm",
"contents": "%view.workbench.scm.workspace%",
"when": "config.git.enabled && !git.missing && workbenchState == workspace"
"when": "config.git.enabled && !git.missing && workbenchState == workspace && workspaceFolderCount != 0"
},
{
"view": "workbench.scm",
"contents": "%view.workbench.scm.emptyWorkspace%",
"when": "config.git.enabled && !git.missing && workbenchState == workspace && workspaceFolderCount == 0"
},
{
"view": "workbench.explorer.emptyView",
"contents": "%view.workbench.cloneRepository%"
}
]
},
Expand Down
8 changes: 5 additions & 3 deletions extensions/git/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,9 @@
"colors.submodule": "Color for submodule resources.",
"view.workbench.scm.missing": "A valid git installation was not detected, more details can be found in the [git output](command:git.showOutput).\nPlease [install git](https://git-scm.com/), or learn more about how to use Git and source control in VS Code in [our docs](https://aka.ms/vscode-scm).\nIf you're using a different version control system, you can [search the Marketplace](command:workbench.extensions.search?%22%40category%3A%5C%22scm%20providers%5C%22%22) for additional extensions.",
"view.workbench.scm.disabled": "If you would like to use git features, please enable git in your [settings](command:workbench.action.openSettings?%5B%22git.enabled%22%5D).\nTo learn more about how to use Git and source control in VS Code [read our docs](https://aka.ms/vscode-scm).",
"view.workbench.scm.empty": "In order to use git features, you can open a folder containing a git repository or clone from a URL.\n[Open Folder](command:vscode.openFolder)\n[Clone from URL](command:git.clone)\nTo learn more about how to use Git and source control in VS Code [read our docs](https://aka.ms/vscode-scm).",
"view.workbench.scm.folder": "The folder currently open doesn't have a git repository.\n[Initialize Repository](command:git.init)\nTo learn more about how to use Git and source control in VS Code [read our docs](https://aka.ms/vscode-scm).",
"view.workbench.scm.workspace": "The workspace currently open doesn't have any folders containing git repositories.\n[Initialize Repository](command:git.init)\nTo learn more about how to use Git and source control in VS Code [read our docs](https://aka.ms/vscode-scm)."
"view.workbench.scm.empty": "In order to use git features, you can open a folder containing a git repository or clone from a URL.\n[Open Folder](command:vscode.openFolder)\n[Clone Repository](command:git.clone)\nTo learn more about how to use Git and source control in VS Code [read our docs](https://aka.ms/vscode-scm).",
"view.workbench.scm.folder": "The folder currently open doesn't have a git repository.\n[Initialize Repository](command:git.init?%5Btrue%5D)\nTo learn more about how to use Git and source control in VS Code [read our docs](https://aka.ms/vscode-scm).",
"view.workbench.scm.workspace": "The workspace currently open doesn't have any folders containing git repositories.\n[Initialize Repository](command:git.init)\nTo learn more about how to use Git and source control in VS Code [read our docs](https://aka.ms/vscode-scm).",
"view.workbench.scm.emptyWorkspace": "The workspace currently open doesn't have any folders containing git repositories.\n[Add Folder to Workspace](command:workbench.action.addRootFolder)\nTo learn more about how to use Git and source control in VS Code [read our docs](https://aka.ms/vscode-scm).",
"view.workbench.cloneRepository": "You can also clone a repository from a URL. To learn more about how to use Git and source control in VS Code [read our docs](https://aka.ms/vscode-scm).\n[Clone Repository](command:git.clone)"
}
31 changes: 18 additions & 13 deletions extensions/git/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,24 +566,29 @@ export class CommandCenter {
}

@command('git.init')
async init(): Promise<void> {
async init(skipFolderPrompt = false): Promise<void> {
let repositoryPath: string | undefined = undefined;
let askToOpen = true;

if (workspace.workspaceFolders) {
const placeHolder = localize('init', "Pick workspace folder to initialize git repo in");
const pick = { label: localize('choose', "Choose Folder...") };
const items: { label: string, folder?: WorkspaceFolder }[] = [
...workspace.workspaceFolders.map(folder => ({ label: folder.name, description: folder.uri.fsPath, folder })),
pick
];
const item = await window.showQuickPick(items, { placeHolder, ignoreFocusOut: true });

if (!item) {
return;
} else if (item.folder) {
repositoryPath = item.folder.uri.fsPath;
if (skipFolderPrompt && workspace.workspaceFolders.length === 1) {
repositoryPath = workspace.workspaceFolders[0].uri.fsPath;
askToOpen = false;
} else {
const placeHolder = localize('init', "Pick workspace folder to initialize git repo in");
const pick = { label: localize('choose', "Choose Folder...") };
const items: { label: string, folder?: WorkspaceFolder }[] = [
...workspace.workspaceFolders.map(folder => ({ label: folder.name, description: folder.uri.fsPath, folder })),
pick
];
const item = await window.showQuickPick(items, { placeHolder, ignoreFocusOut: true });

if (!item) {
return;
} else if (item.folder) {
repositoryPath = item.folder.uri.fsPath;
askToOpen = false;
}
}
}

Expand Down
18 changes: 16 additions & 2 deletions extensions/vscode-account/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "vscode-account",
"publisher": "vscode",
"displayName": "Account",
"description": "",
"displayName": "%displayName%",
"description": "%description%",
"version": "0.0.1",
"engines": {
"vscode": "^1.42.0"
Expand All @@ -15,6 +15,20 @@
"*"
],
"main": "./out/extension.js",
"contributes": {
"commands": [
{
"command": "microsoft.signin",
"title": "%signIn%",
"category": "%displayName%"
},
{
"command": "microsoft.signout",
"title": "%signOut%",
"category": "%displayName%"
}
]
},
"scripts": {
"vscode:prepublish": "npm run compile",
"compile": "gulp compile-extension:vscode-account",
Expand Down
6 changes: 6 additions & 0 deletions extensions/vscode-account/package.nls.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"displayName": "Microsoft Account",
"description": "Microsoft authentication provider",
"signIn": "Sign in",
"signOut": "Sign out"
}
38 changes: 35 additions & 3 deletions extensions/vscode-account/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@
import * as vscode from 'vscode';
import { AzureActiveDirectoryService, onDidChangeSessions } from './AADHelper';

export async function activate(_: vscode.ExtensionContext) {
export const DEFAULT_SCOPES = 'https://management.core.windows.net/.default offline_access';

export async function activate(context: vscode.ExtensionContext) {

const loginService = new AzureActiveDirectoryService();

await loginService.initialize();

vscode.authentication.registerAuthenticationProvider({
context.subscriptions.push(vscode.authentication.registerAuthenticationProvider({
id: 'MSA',
displayName: 'Microsoft',
onDidChangeSessions: onDidChangeSessions.event,
Expand All @@ -28,7 +30,37 @@ export async function activate(_: vscode.ExtensionContext) {
logout: async (id: string) => {
return loginService.logout(id);
}
});
}));

context.subscriptions.push(vscode.commands.registerCommand('microsoft.signin', () => {
return loginService.login(DEFAULT_SCOPES);
}));

context.subscriptions.push(vscode.commands.registerCommand('microsoft.signout', async () => {
const sessions = loginService.sessions;
if (sessions.length === 0) {
return;
}

if (sessions.length === 1) {
await loginService.logout(loginService.sessions[0].id);
onDidChangeSessions.fire();
return;
}

const selectedSession = await vscode.window.showQuickPick(sessions.map(session => {
return {
id: session.id,
label: session.accountName
};
}));

if (selectedSession) {
await loginService.logout(selectedSession.id);
onDidChangeSessions.fire();
return;
}
}));

return;
}
Expand Down
8 changes: 5 additions & 3 deletions src/vs/base/browser/ui/codiconLabel/codicon/codicon.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

@font-face {
font-family: "codicon";
src: url("./codicon.ttf?d0510f6ecacbb2788db2b3162273a3d8") format("truetype");
src: url("./codicon.ttf?279add2ec8b3d516ca20a123230cbf9f") format("truetype");
}

.codicon[class*='codicon-'] {
Expand Down Expand Up @@ -303,6 +303,7 @@
.codicon-paintcan:before { content: "\eb2a" }
.codicon-pin:before { content: "\eb2b" }
.codicon-play:before { content: "\eb2c" }
.codicon-run:before { content: "\eb2c" }
.codicon-plug:before { content: "\eb2d" }
.codicon-preserve-case:before { content: "\eb2e" }
.codicon-preview:before { content: "\eb2f" }
Expand Down Expand Up @@ -413,5 +414,6 @@
.codicon-feedback:before { content: "\eb96" }
.codicon-group-by-ref-type:before { content: "\eb97" }
.codicon-ungroup-by-ref-type:before { content: "\eb98" }
.codicon-debug-alt-2:before { content: "\f101" }
.codicon-debug-alt:before { content: "\f102" }
.codicon-bell-dot:before { content: "\f101" }
.codicon-debug-alt-2:before { content: "\f102" }
.codicon-debug-alt:before { content: "\f103" }
Binary file modified src/vs/base/browser/ui/codiconLabel/codicon/codicon.ttf
Binary file not shown.
9 changes: 8 additions & 1 deletion src/vs/base/browser/ui/list/listView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface IListViewOptions<T> {
readonly useShadows?: boolean;
readonly verticalScrollMode?: ScrollbarVisibility;
readonly setRowLineHeight?: boolean;
readonly setRowHeight?: boolean;
readonly supportDynamicHeights?: boolean;
readonly mouseSupport?: boolean;
readonly horizontalScrolling?: boolean;
Expand All @@ -63,6 +64,7 @@ const DefaultOptions = {
useShadows: true,
verticalScrollMode: ScrollbarVisibility.Auto,
setRowLineHeight: true,
setRowHeight: true,
supportDynamicHeights: false,
dnd: {
getDragElements<T>(e: T) { return [e]; },
Expand Down Expand Up @@ -174,6 +176,7 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
private dragOverAnimationStopDisposable: IDisposable = Disposable.None;
private dragOverMouseY: number = 0;
private setRowLineHeight: boolean;
private setRowHeight: boolean;
private supportDynamicHeights: boolean;
private horizontalScrolling: boolean;
private additionalScrollHeight: number;
Expand Down Expand Up @@ -262,6 +265,7 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
domEvent(window, 'dragend')(this.onDragEnd, this, this.disposables);

this.setRowLineHeight = getOrDefault(options, o => o.setRowLineHeight, DefaultOptions.setRowLineHeight);
this.setRowHeight = getOrDefault(options, o => o.setRowHeight, DefaultOptions.setRowHeight);
this.supportDynamicHeights = getOrDefault(options, o => o.supportDynamicHeights, DefaultOptions.supportDynamicHeights);
this.dnd = getOrDefault<IListViewOptions<T>, IListViewDragAndDrop<T>>(options, o => o.dnd, DefaultOptions.dnd);

Expand Down Expand Up @@ -614,7 +618,10 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {

private updateItemInDOM(item: IItem<T>, index: number): void {
item.row!.domNode!.style.top = `${this.elementTop(index)}px`;
item.row!.domNode!.style.height = `${item.size}px`;

if (this.setRowHeight) {
item.row!.domNode!.style.height = `${item.size}px`;
}

if (this.setRowLineHeight) {
item.row!.domNode!.style.lineHeight = `${item.size}px`;
Expand Down
1 change: 1 addition & 0 deletions src/vs/base/browser/ui/list/listWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,7 @@ export interface IListOptions<T> {
readonly useShadows?: boolean;
readonly verticalScrollMode?: ScrollbarVisibility;
readonly setRowLineHeight?: boolean;
readonly setRowHeight?: boolean;
readonly supportDynamicHeights?: boolean;
readonly mouseSupport?: boolean;
readonly horizontalScrolling?: boolean;
Expand Down
3 changes: 1 addition & 2 deletions src/vs/base/parts/quickinput/browser/quickInputList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,7 @@ export class QuickInputList {
if ((what === 'Previous' || what === 'PreviousPage') && this.list.getFocus()[0] === 0) {
what = 'Last';
}

(this.list as any)['focus' + what]();
this.list['focus' + what as 'focusFirst' | 'focusLast' | 'focusNext' | 'focusPrevious' | 'focusNextPage' | 'focusPreviousPage']();
this.list.reveal(this.list.getFocus()[0]);
}

Expand Down
Loading

0 comments on commit 0cec223

Please sign in to comment.