Skip to content

Commit

Permalink
Merge branch 'master' into joao/compressed-trees
Browse files Browse the repository at this point in the history
  • Loading branch information
joaomoreno authored Sep 11, 2019
2 parents ab021bf + 67dc534 commit 69b97db
Show file tree
Hide file tree
Showing 57 changed files with 677 additions and 637 deletions.
30 changes: 29 additions & 1 deletion build/gulpfile.hygiene.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const vfs = require('vinyl-fs');
const path = require('path');
const fs = require('fs');
const pall = require('p-all');
const task = require('./lib/task');

/**
* Hygiene works by creating cascading subsets of all our files and
Expand Down Expand Up @@ -205,6 +206,33 @@ gulp.task('tslint', () => {
]).pipe(es.through());
});

function checkPackageJSON(actualPath) {
const actual = require(path.join(__dirname, '..', actualPath));
const rootPackageJSON = require('../package.json');

for (let depName in actual.dependencies) {
const depVersion = actual.dependencies[depName];
const rootDepVersion = rootPackageJSON.dependencies[depName];
if (!rootDepVersion) {
// missing in root is allowed
continue;
}
if (depVersion !== rootDepVersion) {
this.emit('error', `The dependency ${depName} in '${actualPath}' (${depVersion}) is different than in the root package.json (${rootDepVersion})`);
}
}
}

const checkPackageJSONTask = task.define('check-package-json', () => {
return gulp.src('package.json')
.pipe(es.through(function() {
checkPackageJSON.call(this, 'remote/package.json');
checkPackageJSON.call(this, 'remote/web/package.json');
}));
});
gulp.task(checkPackageJSONTask);


function hygiene(some) {
let errorCount = 0;

Expand Down Expand Up @@ -393,7 +421,7 @@ function createGitIndexVinyls(paths) {
.then(r => r.filter(p => !!p));
}

gulp.task('hygiene', () => hygiene());
gulp.task('hygiene', task.series(checkPackageJSONTask, () => hygiene()));

// this allows us to run hygiene as a git pre-commit hook
if (require.main === module) {
Expand Down
2 changes: 1 addition & 1 deletion build/gulpfile.vscode.linux.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ function prepareSnapPackage(arch) {
.pipe(replace('@@NAME_LONG@@', product.nameLong))
.pipe(replace('@@NAME_SHORT@@', product.nameShort))
.pipe(replace('@@NAME@@', product.applicationName))
.pipe(replace('@@EXEC@@', product.applicationName))
.pipe(replace('@@EXEC@@', `${product.applicationName} --force-user-env`))
.pipe(replace('@@ICON@@', `\${SNAP}/meta/gui/${product.linuxIconName}.png`))
.pipe(replace('@@URLPROTOCOL@@', product.urlProtocol));

Expand Down
159 changes: 6 additions & 153 deletions build/gulpfile.vscode.web.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,158 +6,11 @@
'use strict';

const gulp = require('gulp');
const path = require('path');
const es = require('event-stream');
const util = require('./lib/util');
const task = require('./lib/task');
const common = require('./lib/optimize');
const product = require('../product.json');
const rename = require('gulp-rename');
const filter = require('gulp-filter');
const json = require('gulp-json-editor');
const _ = require('underscore');
const deps = require('./dependencies');
const vfs = require('vinyl-fs');
const packageJson = require('../package.json');
const { compileBuildTask } = require('./gulpfile.compile');

const REPO_ROOT = path.dirname(__dirname);
const commit = util.getVersion(REPO_ROOT);
const BUILD_ROOT = path.dirname(REPO_ROOT);
const WEB_FOLDER = path.join(REPO_ROOT, 'remote', 'web');
const noop = () => { return Promise.resolve(); };

const productionDependencies = deps.getProductionDependencies(WEB_FOLDER);

const nodeModules = Object.keys(product.dependencies || {})
.concat(_.uniq(productionDependencies.map(d => d.name)));

const vscodeWebResources = [

// Workbench
'out-build/vs/{base,platform,editor,workbench}/**/*.{svg,png}',
'out-build/vs/code/browser/workbench/*.html',
'out-build/vs/base/browser/ui/octiconLabel/octicons/**',
'out-build/vs/**/markdown.css',

// Webview
'out-build/vs/workbench/contrib/webview/browser/pre/*.js',

// Extension Worker
'out-build/vs/workbench/services/extensions/worker/extensionHostWorkerMain.js',

// Excludes
'!out-build/vs/**/{node,electron-browser,electron-main}/**',
'!out-build/vs/editor/standalone/**',
'!out-build/vs/workbench/**/*-tb.png',
'!**/test/**'
];

const buildfile = require('../src/buildfile');

const vscodeWebEntryPoints = _.flatten([
buildfile.entrypoint('vs/workbench/workbench.web.api'),
buildfile.base,
buildfile.workerExtensionHost,
buildfile.keyboardMaps,
buildfile.workbenchWeb
]);

const optimizeVSCodeWebTask = task.define('optimize-vscode-web', task.series(
util.rimraf('out-vscode-web'),
common.optimizeTask({
src: 'out-build',
entryPoints: _.flatten(vscodeWebEntryPoints),
otherSources: [],
resources: vscodeWebResources,
loaderConfig: common.loaderConfig(nodeModules),
out: 'out-vscode-web',
bundleInfo: undefined
})
));

const minifyVSCodeWebTask = task.define('minify-vscode-web', task.series(
optimizeVSCodeWebTask,
util.rimraf('out-vscode-web-min'),
common.minifyTask('out-vscode-web', `https://ticino.blob.core.windows.net/sourcemaps/${commit}/core`)
));
gulp.task(minifyVSCodeWebTask);

function packageTask(sourceFolderName, destinationFolderName) {
const destination = path.join(BUILD_ROOT, destinationFolderName);

return () => {
const src = gulp.src(sourceFolderName + '/**', { base: '.' })
.pipe(rename(function (path) { path.dirname = path.dirname.replace(new RegExp('^' + sourceFolderName), 'out'); }))
.pipe(filter(['**', '!**/*.js.map']));

const sources = es.merge(src);

let version = packageJson.version;
const quality = product.quality;

if (quality && quality !== 'stable') {
version += '-' + quality;
}

const name = product.nameShort;
const packageJsonStream = gulp.src(['remote/web/package.json'], { base: 'remote/web' })
.pipe(json({ name, version }));

const date = new Date().toISOString();

const productJsonStream = gulp.src(['product.json'], { base: '.' })
.pipe(json({ commit, date }));

const license = gulp.src(['remote/LICENSE'], { base: 'remote' });

const dependenciesSrc = _.flatten(productionDependencies.map(d => path.relative(REPO_ROOT, d.path)).map(d => [`${d}/**`, `!${d}/**/{test,tests}/**`, `!${d}/.bin/**`]));

const deps = gulp.src(dependenciesSrc, { base: 'remote/web', dot: true })
.pipe(filter(['**', '!**/package-lock.json']))
.pipe(util.cleanNodeModules(path.join(__dirname, '.nativeignore')));

const favicon = gulp.src('resources/server/favicon.ico', { base: 'resources/server' });
const manifest = gulp.src('resources/server/manifest.json', { base: 'resources/server' });
const pwaicons = es.merge(
gulp.src('resources/server/code-192.png', { base: 'resources/server' }),
gulp.src('resources/server/code-512.png', { base: 'resources/server' })
);

let all = es.merge(
packageJsonStream,
productJsonStream,
license,
sources,
deps,
favicon,
manifest,
pwaicons
);

let result = all
.pipe(util.skipDirectories())
.pipe(util.fixWin32DirectoryPermissions());

return result.pipe(vfs.dest(destination));
};
}

const dashed = (str) => (str ? `-${str}` : ``);

['', 'min'].forEach(minified => {
const sourceFolderName = `out-vscode-web${dashed(minified)}`;
const destinationFolderName = `vscode-web`;

const vscodeWebTaskCI = task.define(`vscode-web${dashed(minified)}-ci`, task.series(
minified ? minifyVSCodeWebTask : optimizeVSCodeWebTask,
util.rimraf(path.join(BUILD_ROOT, destinationFolderName)),
packageTask(sourceFolderName, destinationFolderName)
));
gulp.task(vscodeWebTaskCI);

const vscodeWebTask = task.define(`vscode-web${dashed(minified)}`, task.series(
compileBuildTask,
vscodeWebTaskCI
));
gulp.task(vscodeWebTask);
});
gulp.task('minify-vscode-web', noop);
gulp.task('vscode-web', noop);
gulp.task('vscode-web-min', noop);
gulp.task('vscode-web-ci', noop);
gulp.task('vscode-web-min-ci', noop);
4 changes: 2 additions & 2 deletions extensions/cpp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
"contributes": {
"languages": [{
"id": "c",
"extensions": [ ".c"],
"extensions": [ ".c", ".i"],
"aliases": [ "C", "c" ],
"configuration": "./language-configuration.json"
},
{
"id": "cpp",
"extensions": [ ".cpp", ".cc", ".cxx", ".c++", ".hpp", ".hh", ".hxx", ".h", ".i", ".ino", ".inl", ".ipp", ".hpp.in", ".h.in" ],
"extensions": [ ".cpp", ".cc", ".cxx", ".c++", ".hpp", ".hh", ".hxx", ".h", ".ii", ".ino", ".inl", ".ipp", ".hpp.in", ".h.in" ],
"aliases": [ "C++", "Cpp", "cpp"],
"configuration": "./language-configuration.json"
}],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -897,4 +897,23 @@ suite('workspace-namespace', () => {
await delay(10);
}
}

test('The api workspace.applyEdit failed for some case of mixing resourceChange and textEdit #80688', async function () {
const file1 = await createRandomFile();
const file2 = await createRandomFile();
let we = new vscode.WorkspaceEdit();
we.insert(file1, new vscode.Position(0, 0), 'import1;');

const file2Name = basename(file2.fsPath);
const file2NewUri = vscode.Uri.parse(file2.toString().replace(file2Name, `new/${file2Name}`));
we.renameFile(file2, file2NewUri);

we.insert(file1, new vscode.Position(0, 0), 'import2;');
await vscode.workspace.applyEdit(we);

const document = await vscode.workspace.openTextDocument(file1);
// const expected = 'import1;import2;';
const expected2 = 'import2;import1;';
assert.equal(document.getText(), expected2);
});
});
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.39.0",
"distro": "cb09cfe757e21433d881c094f41fa24e0545d05d",
"distro": "5021d1d3791476c5180209e093da67e5124977fe",
"author": {
"name": "Microsoft Corporation"
},
Expand Down
4 changes: 2 additions & 2 deletions resources/linux/snap/snapcraft.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ parts:

apps:
@@NAME@@:
command: electron-launch $SNAP/usr/share/@@NAME@@/@@NAME@@
command: electron-launch $SNAP/usr/share/@@NAME@@/bin/@@NAME@@
common-id: @@NAME@@.desktop
environment:
DISABLE_WAYLAND: 1
GSETTINGS_SCHEMA_DIR: $SNAP/usr/share/glib-2.0/schemas

url-handler:
command: electron-launch $SNAP/usr/share/@@NAME@@/@@NAME@@ --open-url
command: electron-launch $SNAP/usr/share/@@NAME@@/bin/@@NAME@@ --open-url
environment:
DISABLE_WAYLAND: 1
GSETTINGS_SCHEMA_DIR: $SNAP/usr/share/glib-2.0/schemas
2 changes: 1 addition & 1 deletion src/vs/base/browser/dom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1193,7 +1193,7 @@ export function asDomUri(uri: URI): URI {
return uri;
}
if (Schemas.vscodeRemote === uri.scheme) {
return RemoteAuthorities.rewrite(uri.authority, uri.path);
return RemoteAuthorities.rewrite(uri);
}
return uri;
}
Expand Down
13 changes: 13 additions & 0 deletions src/vs/base/browser/ui/inputbox/inputBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,19 @@ export class InputBox extends Widget {
}
}

public insertAtCursor(text: string): void {
const inputElement = this.inputElement;
const start = inputElement.selectionStart;
const end = inputElement.selectionEnd;
const content = inputElement.value;

if (start !== null && end !== null) {
this.value = content.substr(0, start) + text + content.substr(end);
inputElement.setSelectionRange(start + 1, start + 1);
this.layout();
}
}

public dispose(): void {
this._hideMessage();

Expand Down
17 changes: 14 additions & 3 deletions src/vs/base/common/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { URI } from 'vs/base/common/uri';
import { URI, UriComponents } from 'vs/base/common/uri';
import * as platform from 'vs/base/common/platform';

export namespace Schemas {
Expand Down Expand Up @@ -60,18 +60,24 @@ class RemoteAuthoritiesImpl {
private readonly _ports: { [authority: string]: number; };
private readonly _connectionTokens: { [authority: string]: string; };
private _preferredWebSchema: 'http' | 'https';
private _delegate: ((uri: URI) => UriComponents) | null;

constructor() {
this._hosts = Object.create(null);
this._ports = Object.create(null);
this._connectionTokens = Object.create(null);
this._preferredWebSchema = 'http';
this._delegate = null;
}

public setPreferredWebSchema(schema: 'http' | 'https') {
this._preferredWebSchema = schema;
}

public setDelegate(delegate: (uri: URI) => UriComponents): void {
this._delegate = delegate;
}

public set(authority: string, host: string, port: number): void {
this._hosts[authority] = host;
this._ports[authority] = port;
Expand All @@ -81,15 +87,20 @@ class RemoteAuthoritiesImpl {
this._connectionTokens[authority] = connectionToken;
}

public rewrite(authority: string, path: string): URI {
public rewrite(uri: URI): URI {
if (this._delegate) {
const result = this._delegate(uri);
return URI.revive(result);
}
const authority = uri.authority;
const host = this._hosts[authority];
const port = this._ports[authority];
const connectionToken = this._connectionTokens[authority];
return URI.from({
scheme: platform.isWeb ? this._preferredWebSchema : Schemas.vscodeRemoteResource,
authority: `${host}:${port}`,
path: `/vscode-remote-resource`,
query: `path=${encodeURIComponent(path)}&tkn=${encodeURIComponent(connectionToken)}`
query: `path=${encodeURIComponent(uri.path)}&tkn=${encodeURIComponent(connectionToken)}`
});
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/vs/code/browser/workbench/workbench-dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
default-src 'self';
img-src 'self' https: data: blob:;
media-src 'none';
script-src 'self' https://az416426.vo.msecnd.net 'unsafe-eval' https: 'sha256-4DqvCTjCHj2KW4QxC/Yt6uBwMRyYiEg7kOoykSEkonQ=' 'sha256-4i4ZKOTzR9VPdhew0hOqnhvy09L6eRM2iyzJlc5loi4=';
script-src 'self' https://az416426.vo.msecnd.net 'unsafe-eval' https: 'sha256-4DqvCTjCHj2KW4QxC/Yt6uBwMRyYiEg7kOoykSEkonQ=' 'sha256-meDZW3XhN5JmdjFUrWGhTouRKBiWYtXHltaKnqn/WMo=';
child-src 'self';
frame-src 'self' {{WEBVIEW_ENDPOINT}} https://*.vscode-webview-test.com;
worker-src 'self';
Expand Down Expand Up @@ -57,8 +57,6 @@
<script src="./static/out/vs/loader.js"></script>
<script>
// NOTE: Changes to inline scripts require update of content security policy
require(['vs/code/browser/workbench/workbench'], function (web) {
web.main();
});
require(['vs/code/browser/workbench/workbench'], function() {});
</script>
</html>
Loading

0 comments on commit 69b97db

Please sign in to comment.