Skip to content

Commit

Permalink
Merge branch 'main' into nodejsWalkthrough
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Sep 14, 2022
2 parents d0d911d + 00902da commit 000dfdb
Show file tree
Hide file tree
Showing 159 changed files with 3,138 additions and 1,313 deletions.
15 changes: 0 additions & 15 deletions .github/commands.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,6 @@
"reason": "not_planned",
"comment": "The described behavior is how it is expected to work. If you disagree, please explain what is expected and what is not in more detail. See also our [issue reporting guidelines](https://aka.ms/vscodeissuereporting).\n\nHappy Coding!"
},
{
"type": "label",
"name": "notebook",
"regex": "notebook.*",
"assign": [
"rebornix"
]
},
{
"type": "label",
"name": "notebook-triage",
"regex": "notebook.*",
"action": "updateLabels",
"addLabel": "notebook-triage"
},
{
"type": "label",
"name": "L10N",
Expand Down
25 changes: 20 additions & 5 deletions build/azure-pipelines/product-build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ jobs:
- ${{ if ne(variables['VSCODE_CIBUILD'], true) }}:
- job: Compile
displayName: Compile & Hygiene
pool: vscode-1es-vscode-linux-20.04
pool:
name: vscode-1es-vscode-linux-20.04
demands:
- ImageVersionOverride -equals 40.0.0
timeoutInMinutes: 30
variables:
VSCODE_ARCH: x64
Expand All @@ -37,7 +40,10 @@ jobs:

- job: Linuxx64UnitTest
displayName: Linux (Unit Tests)
pool: vscode-1es-vscode-linux-20.04
pool:
name: vscode-1es-vscode-linux-20.04
demands:
- ImageVersionOverride -equals 40.0.0
timeoutInMinutes: 30
variables:
VSCODE_ARCH: x64
Expand All @@ -54,7 +60,10 @@ jobs:

- job: Linuxx64IntegrationTest
displayName: Linux (Integration Tests)
pool: vscode-1es-vscode-linux-20.04
pool:
name: vscode-1es-vscode-linux-20.04
demands:
- ImageVersionOverride -equals 40.0.0
timeoutInMinutes: 30
variables:
VSCODE_ARCH: x64
Expand All @@ -71,7 +80,10 @@ jobs:

- job: Linuxx64SmokeTest
displayName: Linux (Smoke Tests)
pool: vscode-1es-vscode-linux-20.04
pool:
name: vscode-1es-vscode-linux-20.04
demands:
- ImageVersionOverride -equals 40.0.0
timeoutInMinutes: 30
variables:
VSCODE_ARCH: x64
Expand All @@ -89,7 +101,10 @@ jobs:
- ${{ if eq(variables['VSCODE_CIBUILD'], true) }}:
- job: Linuxx64MaintainNodeModulesCache
displayName: Linux (Maintain node_modules cache)
pool: vscode-1es-vscode-linux-20.04
pool:
name: vscode-1es-vscode-linux-20.04
demands:
- ImageVersionOverride -equals 40.0.0
timeoutInMinutes: 30
variables:
VSCODE_ARCH: x64
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ export function getDocumentContext(documentUri: string, workspaceFolders: Worksp
return folderUri + ref.substring(1);
}
}
base = base.substring(0, base.lastIndexOf('/') + 1);
return Utils.resolvePath(URI.parse(base), ref).toString(true);
const baseUri = URI.parse(base);
const baseUriDir = baseUri.path.endsWith('/') ? baseUri : Utils.dirname(baseUri);
return Utils.resolvePath(baseUriDir, ref).toString(true);
},
};
}
Expand Down
61 changes: 58 additions & 3 deletions extensions/git/src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

import * as os from 'os';
import * as path from 'path';
import { Command, commands, Disposable, LineChange, MessageOptions, Position, ProgressLocation, QuickPickItem, Range, SourceControlResourceState, TextDocumentShowOptions, TextEditor, Uri, ViewColumn, window, workspace, WorkspaceEdit, WorkspaceFolder, TimelineItem, env, Selection, TextDocumentContentProvider, InputBoxValidationSeverity, TabInputText, TabInputTextMerge } from 'vscode';
import { Command, commands, Disposable, LineChange, MessageOptions, Position, ProgressLocation, QuickPickItem, Range, SourceControlResourceState, TextDocumentShowOptions, TextEditor, Uri, ViewColumn, window, workspace, WorkspaceEdit, WorkspaceFolder, TimelineItem, env, Selection, TextDocumentContentProvider, InputBoxValidationSeverity, TabInputText, TabInputTextMerge, QuickPickItemKind } from 'vscode';
import TelemetryReporter from '@vscode/extension-telemetry';
import * as nls from 'vscode-nls';
import { uniqueNamesGenerator, adjectives, animals, colors, NumberDictionary } from '@joaomoreno/unique-names-generator';
import { Branch, ForcePushMode, GitErrorCodes, Ref, RefType, Status, CommitOptions, RemoteSourcePublisher } from './api/git';
import { Branch, ForcePushMode, GitErrorCodes, Ref, RefType, Status, CommitOptions, RemoteSourcePublisher, Remote } from './api/git';
import { Git, Stash } from './git';
import { Model } from './model';
import { Repository, Resource, ResourceGroupType } from './repository';
Expand Down Expand Up @@ -158,6 +158,28 @@ class AddRemoteItem implements QuickPickItem {
}
}

class RemoteItem implements QuickPickItem {
get label() { return `$(cloud) ${this.remote.name}`; }
get description(): string | undefined { return this.remote.fetchUrl; }
get remoteName(): string { return this.remote.name; }

constructor(private readonly repository: Repository, private readonly remote: Remote) { }

async run(): Promise<void> {
await this.repository.fetch({ remote: this.remote.name });
}
}

class FetchAllRemotesItem implements QuickPickItem {
get label(): string { return localize('fetch all remotes', "{0} Fetch all remotes", '$(cloud-download)'); }

constructor(private readonly repository: Repository) { }

async run(): Promise<void> {
await this.repository.fetch({ all: true });
}
}

interface ScmCommandOptions {
repository?: boolean;
diff?: boolean;
Expand Down Expand Up @@ -2294,7 +2316,40 @@ export class CommandCenter {
return;
}

await repository.fetchDefault();
if (repository.remotes.length === 1) {
await repository.fetchDefault();
return;
}

const remoteItems: RemoteItem[] = repository.remotes.map(r => new RemoteItem(repository, r));

if (repository.HEAD?.upstream?.remote) {
// Move default remote to the top
const defaultRemoteIndex = remoteItems
.findIndex(r => r.remoteName === repository.HEAD!.upstream!.remote);

if (defaultRemoteIndex !== -1) {
remoteItems.splice(0, 0, ...remoteItems.splice(defaultRemoteIndex, 1));
}
}

const quickpick = window.createQuickPick();
quickpick.placeholder = localize('select a remote to fetch', 'Select a remote to fetch');
quickpick.canSelectMany = false;
quickpick.items = [...remoteItems, { label: '', kind: QuickPickItemKind.Separator }, new FetchAllRemotesItem(repository)];

quickpick.show();
const remoteItem = await new Promise<RemoteItem | FetchAllRemotesItem | undefined>(resolve => {
quickpick.onDidAccept(() => resolve(quickpick.activeItems[0] as RemoteItem | FetchAllRemotesItem));
quickpick.onDidHide(() => resolve(undefined));
});
quickpick.hide();

if (!remoteItem) {
return;
}

await remoteItem.run();
}

@command('git.fetchPrune', { repository: true })
Expand Down
4 changes: 2 additions & 2 deletions extensions/html-language-features/server/src/node/nodeFs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { FileSystemProvider, getScheme } from '../requests';
import { FileSystemProvider } from '../requests';
import { URI as Uri } from 'vscode-uri';

import * as fs from 'fs';
import { FileType } from 'vscode-css-languageservice';

export function getNodeFileFS(): FileSystemProvider {
function ensureFileUri(location: string) {
if (getScheme(location) !== 'file') {
if (!location.startsWith('file:')) {
throw new Error('fileSystemProvider can only handle file URLs');
}
}
Expand Down
78 changes: 0 additions & 78 deletions extensions/html-language-features/server/src/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { URI } from 'vscode-uri';
import { RequestType, Connection } from 'vscode-languageserver';
import { RuntimeEnvironment } from './htmlServer';

Expand Down Expand Up @@ -77,80 +76,3 @@ export function getFileSystemProvider(handledSchemas: string[], connection: Conn
}
};
}

export function getScheme(uri: string) {
return uri.substr(0, uri.indexOf(':'));
}

export function dirname(uri: string) {
const lastIndexOfSlash = uri.lastIndexOf('/');
return lastIndexOfSlash !== -1 ? uri.substr(0, lastIndexOfSlash) : '';
}

export function basename(uri: string) {
const lastIndexOfSlash = uri.lastIndexOf('/');
return uri.substr(lastIndexOfSlash + 1);
}


const Slash = '/'.charCodeAt(0);
const Dot = '.'.charCodeAt(0);

export function extname(uri: string) {
for (let i = uri.length - 1; i >= 0; i--) {
const ch = uri.charCodeAt(i);
if (ch === Dot) {
if (i > 0 && uri.charCodeAt(i - 1) !== Slash) {
return uri.substr(i);
} else {
break;
}
} else if (ch === Slash) {
break;
}
}
return '';
}

export function isAbsolutePath(path: string) {
return path.charCodeAt(0) === Slash;
}

export function resolvePath(uriString: string, path: string): string {
if (isAbsolutePath(path)) {
const uri = URI.parse(uriString);
const parts = path.split('/');
return uri.with({ path: normalizePath(parts) }).toString();
}
return joinPath(uriString, path);
}

export function normalizePath(parts: string[]): string {
const newParts: string[] = [];
for (const part of parts) {
if (part.length === 0 || part.length === 1 && part.charCodeAt(0) === Dot) {
// ignore
} else if (part.length === 2 && part.charCodeAt(0) === Dot && part.charCodeAt(1) === Dot) {
newParts.pop();
} else {
newParts.push(part);
}
}
if (parts.length > 1 && parts[parts.length - 1].length === 0) {
newParts.push('');
}
let res = newParts.join('/');
if (parts[0].length === 0) {
res = '/' + res;
}
return res;
}

export function joinPath(uriString: string, ...paths: string[]): string {
const uri = URI.parse(uriString);
const parts = uri.path.split('/');
for (const path of paths) {
parts.push(...path.split('/'));
}
return uri.with({ path: normalizePath(parts) }).toString();
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { DocumentContext } from 'vscode-css-languageservice';
import { endsWith, startsWith } from '../utils/strings';
import { WorkspaceFolder } from 'vscode-languageserver';
import { resolvePath } from '../requests';
import { URI, Utils } from 'vscode-uri';

export function getDocumentContext(documentUri: string, workspaceFolders: WorkspaceFolder[]): DocumentContext {
function getRootFolder(): string | undefined {
Expand Down Expand Up @@ -34,8 +34,9 @@ export function getDocumentContext(documentUri: string, workspaceFolders: Worksp
return folderUri + ref.substr(1);
}
}
base = base.substr(0, base.lastIndexOf('/') + 1);
return resolvePath(base, ref);
const baseUri = URI.parse(base);
const baseUriDir = baseUri.path.endsWith('/') ? baseUri : Utils.dirname(baseUri);
return Utils.resolvePath(baseUriDir, ref).toString(true);
},
};
}
Expand Down
27 changes: 12 additions & 15 deletions extensions/ipynb/src/serializers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type * as nbformat from '@jupyterlab/nbformat';
import { NotebookCell, NotebookCellData, NotebookCellKind, NotebookCellOutput } from 'vscode';
import { CellMetadata, CellOutputMetadata } from './common';
import { textMimeTypes } from './deserializers';
import { compressOutputItemStreams } from './streamCompressor';

const textDecoder = new TextDecoder();

Expand Down Expand Up @@ -270,21 +271,17 @@ type JupyterOutput =

function convertStreamOutput(output: NotebookCellOutput): JupyterOutput {
const outputs: string[] = [];
output.items
.filter((opit) => opit.mime === CellOutputMimeTypes.stderr || opit.mime === CellOutputMimeTypes.stdout)
.map((opit) => textDecoder.decode(opit.data))
.forEach(value => {
// Ensure each line is a seprate entry in an array (ending with \n).
const lines = value.split('\n');
// If the last item in `outputs` is not empty and the first item in `lines` is not empty, then concate them.
// As they are part of the same line.
if (outputs.length && lines.length && lines[0].length > 0) {
outputs[outputs.length - 1] = `${outputs[outputs.length - 1]}${lines.shift()!}`;
}
for (const line of lines) {
outputs.push(line);
}
});
const compressedStream = output.items.length ? new TextDecoder().decode(compressOutputItemStreams(output.items[0].mime, output.items)) : '';
// Ensure each line is a separate entry in an array (ending with \n).
const lines = compressedStream.split('\n');
// If the last item in `outputs` is not empty and the first item in `lines` is not empty, then concate them.
// As they are part of the same line.
if (outputs.length && lines.length && lines[0].length > 0) {
outputs[outputs.length - 1] = `${outputs[outputs.length - 1]}${lines.shift()!}`;
}
for (const line of lines) {
outputs.push(line);
}

for (let index = 0; index < (outputs.length - 1); index++) {
outputs[index] = `${outputs[index]}\n`;
Expand Down

0 comments on commit 000dfdb

Please sign in to comment.