Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463 (#7206)

* Merge from vscode 64980ea1f3f532c82bb6c28d27bba9ef2c5b4463

* fix config changes

* fix strictnull checks
This commit is contained in:
Anthony Dresser
2019-09-15 22:38:26 -07:00
committed by GitHub
parent fa6c52699e
commit ea0f9e6ce9
1226 changed files with 21541 additions and 17633 deletions

6
.prettierrc.json Normal file
View File

@@ -0,0 +1,6 @@
{
"useTabs": true,
"printWidth": 120,
"semi": true,
"singleQuote": true
}

View File

@@ -1,3 +1,3 @@
disturl "https://atom.io/download/electron" disturl "https://atom.io/download/electron"
target "4.2.9" target "4.2.10"
runtime "electron" runtime "electron"

View File

@@ -1 +1 @@
2019-07-11T05:47:05.444Z 2019-08-30T20:24:23.714Z

View File

@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -e
REPO="$(pwd)"
# Publish webview contents
PACKAGEJSON="$REPO/package.json"
VERSION=$(node -p "require(\"$PACKAGEJSON\").version")
node build/azure-pipelines/common/publish-webview.js "$REPO/src/vs/workbench/contrib/webview/browser/pre/"

View File

@@ -0,0 +1,87 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as azure from 'azure-storage';
import * as mime from 'mime';
import * as minimist from 'minimist';
import { basename, join } from 'path';
const fileNames = [
'fake.html',
'host.js',
'index.html',
'main.js',
'service-worker.js'
];
async function assertContainer(blobService: azure.BlobService, container: string): Promise<void> {
await new Promise((c, e) => blobService.createContainerIfNotExists(container, { publicAccessLevel: 'blob' }, err => err ? e(err) : c()));
}
async function doesBlobExist(blobService: azure.BlobService, container: string, blobName: string): Promise<boolean | undefined> {
const existsResult = await new Promise<azure.BlobService.BlobResult>((c, e) => blobService.doesBlobExist(container, blobName, (err, r) => err ? e(err) : c(r)));
return existsResult.exists;
}
async function uploadBlob(blobService: azure.BlobService, container: string, blobName: string, file: string): Promise<void> {
const blobOptions: azure.BlobService.CreateBlockBlobRequestOptions = {
contentSettings: {
contentType: mime.lookup(file),
cacheControl: 'max-age=31536000, public'
}
};
await new Promise((c, e) => blobService.createBlockBlobFromLocalFile(container, blobName, file, blobOptions, err => err ? e(err) : c()));
}
async function publish(commit: string, files: readonly string[]): Promise<void> {
console.log('Publishing...');
console.log('Commit:', commit);
const storageAccount = process.env['AZURE_WEBVIEW_STORAGE_ACCOUNT']!;
const blobService = azure.createBlobService(storageAccount, process.env['AZURE_WEBVIEW_STORAGE_ACCESS_KEY']!)
.withFilter(new azure.ExponentialRetryPolicyFilter(20));
await assertContainer(blobService, commit);
for (const file of files) {
const blobName = basename(file);
const blobExists = await doesBlobExist(blobService, commit, blobName);
if (blobExists) {
console.log(`Blob ${commit}, ${blobName} already exists, not publishing again.`);
continue;
}
console.log('Uploading blob to Azure storage...');
await uploadBlob(blobService, commit, blobName, file);
}
console.log('Blobs successfully uploaded.');
}
function main(): void {
const commit = process.env['BUILD_SOURCEVERSION'];
if (!commit) {
console.warn('Skipping publish due to missing BUILD_SOURCEVERSION');
return;
}
const opts = minimist(process.argv.slice(2));
const [directory] = opts._;
const files = fileNames.map(fileName => join(directory, fileName));
publish(commit, files).catch(err => {
console.error(err);
process.exit(1);
});
}
if (process.argv.length < 3) {
console.error('Usage: node publish.js <directory>');
process.exit(-1);
}
main();

View File

@@ -9,7 +9,7 @@ steps:
vstsFeed: '$(ArtifactFeed)' vstsFeed: '$(ArtifactFeed)'
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2 - task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
inputs: inputs:
versionSpec: "1.10.1" versionSpec: "1.x"
- script: | - script: |
yarn --frozen-lockfile yarn --frozen-lockfile
displayName: Install Dependencies displayName: Install Dependencies
@@ -24,8 +24,11 @@ steps:
yarn gulp electron-x64 yarn gulp electron-x64
displayName: Download Electron displayName: Download Electron
- script: | - script: |
yarn gulp hygiene yarn gulp hygiene --skip-tslint
displayName: Run Hygiene Checks displayName: Run Hygiene Checks
- script: |
yarn gulp tslint
displayName: Run TSLint Checks
- script: | - script: |
yarn monaco-compile-check yarn monaco-compile-check
displayName: Run Monaco Editor Checks displayName: Run Monaco Editor Checks

View File

@@ -25,7 +25,7 @@ steps:
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2 - task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
inputs: inputs:
versionSpec: "1.10.1" versionSpec: "1.x"
- task: AzureKeyVault@1 - task: AzureKeyVault@1
displayName: 'Azure Key Vault: Get Secrets' displayName: 'Azure Key Vault: Get Secrets'
@@ -102,20 +102,28 @@ steps:
condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false')) condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false'))
- script: | - script: |
# Figure out the full absolute path of the product we just built
# including the remote server and configure the integration tests
# to run with these builds instead of running out of sources.
set -e set -e
APP_ROOT=$(agent.builddirectory)/VSCode-darwin
APP_NAME="`ls $APP_ROOT | head -n 1`"
INTEGRATION_TEST_ELECTRON_PATH="$APP_ROOT/$APP_NAME/Contents/MacOS/Electron" \
VSCODE_REMOTE_SERVER_PATH="$(agent.builddirectory)/vscode-reh-darwin" \
./scripts/test-integration.sh --build --tfs "Integration Tests" ./scripts/test-integration.sh --build --tfs "Integration Tests"
displayName: Run integration tests displayName: Run integration tests
condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false')) condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false'))
- script: | # Web Smoke Tests disabled due to https://github.com/microsoft/vscode/issues/80308
set -e # - script: |
cd test/smoke # set -e
yarn compile # cd test/smoke
cd - # yarn compile
yarn smoketest --web --headless # cd -
continueOnError: true # yarn smoketest --web --headless
displayName: Run web smoke tests # continueOnError: true
condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false')) # displayName: Run web smoke tests
# condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false'))
- script: | - script: |
set -e set -e

View File

@@ -1,6 +1,13 @@
pool: pool:
vmImage: 'Ubuntu-16.04' vmImage: 'Ubuntu-16.04'
trigger:
branches:
include: ['master']
pr:
branches:
include: ['master']
steps: steps:
- task: NodeTool@0 - task: NodeTool@0
inputs: inputs:
@@ -31,13 +38,3 @@ steps:
git push origin HEAD:electron-6.0.x git push origin HEAD:electron-6.0.x
displayName: Sync & Merge Exploration displayName: Sync & Merge Exploration
trigger: none
pr: none
schedules:
- cron: "0 5 * * Mon-Fri"
displayName: Mon-Fri at 7:00
branches:
include:
- master

View File

@@ -17,7 +17,7 @@ steps:
vstsFeed: '$(ArtifactFeed)' vstsFeed: '$(ArtifactFeed)'
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2 - task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
inputs: inputs:
versionSpec: "1.10.1" versionSpec: "1.x"
- script: | - script: |
yarn --frozen-lockfile yarn --frozen-lockfile
displayName: Install Dependencies displayName: Install Dependencies
@@ -32,8 +32,11 @@ steps:
yarn gulp electron-x64 yarn gulp electron-x64
displayName: Download Electron displayName: Download Electron
- script: | - script: |
yarn gulp hygiene yarn gulp hygiene --skip-tslint
displayName: Run Hygiene Checks displayName: Run Hygiene Checks
- script: |
yarn gulp tslint
displayName: Run TSLint Checks
- script: | - script: |
yarn monaco-compile-check yarn monaco-compile-check
displayName: Run Monaco Editor Checks displayName: Run Monaco Editor Checks

View File

@@ -25,7 +25,7 @@ steps:
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2 - task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
inputs: inputs:
versionSpec: "1.10.1" versionSpec: "1.x"
- task: AzureKeyVault@1 - task: AzureKeyVault@1
displayName: 'Azure Key Vault: Get Secrets' displayName: 'Azure Key Vault: Get Secrets'

View File

@@ -25,7 +25,7 @@ steps:
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2 - task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
inputs: inputs:
versionSpec: "1.10.1" versionSpec: "1.x"
- task: AzureKeyVault@1 - task: AzureKeyVault@1
displayName: 'Azure Key Vault: Get Secrets' displayName: 'Azure Key Vault: Get Secrets'
@@ -105,7 +105,14 @@ steps:
condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false')) condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false'))
- script: | - script: |
# Figure out the full absolute path of the product we just built
# including the remote server and configure the integration tests
# to run with these builds instead of running out of sources.
set -e set -e
APP_ROOT=$(agent.builddirectory)/VSCode-linux-x64
APP_NAME=$(node -p "require(\"$APP_ROOT/resources/app/product.json\").applicationName")
INTEGRATION_TEST_ELECTRON_PATH="$APP_ROOT/$APP_NAME" \
VSCODE_REMOTE_SERVER_PATH="$(agent.builddirectory)/vscode-reh-linux-x64" \
DISPLAY=:10 ./scripts/test-integration.sh --build --tfs "Integration Tests" DISPLAY=:10 ./scripts/test-integration.sh --build --tfs "Integration Tests"
# yarn smoketest -- --build "$(agent.builddirectory)/VSCode-linux-x64" # yarn smoketest -- --build "$(agent.builddirectory)/VSCode-linux-x64"
displayName: Run integration tests displayName: Run integration tests

View File

@@ -5,7 +5,7 @@ steps:
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2 - task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
inputs: inputs:
versionSpec: "1.10.1" versionSpec: "1.x"
- task: AzureKeyVault@1 - task: AzureKeyVault@1
displayName: 'Azure Key Vault: Get Secrets' displayName: 'Azure Key Vault: Get Secrets'
@@ -51,4 +51,4 @@ steps:
# Publish snap package # Publish snap package
AZURE_DOCUMENTDB_MASTERKEY="$(builds-docdb-key-readwrite)" \ AZURE_DOCUMENTDB_MASTERKEY="$(builds-docdb-key-readwrite)" \
AZURE_STORAGE_ACCESS_KEY_2="$(vscode-storage-key)" \ AZURE_STORAGE_ACCESS_KEY_2="$(vscode-storage-key)" \
node build/azure-pipelines/common/publish.js "$VSCODE_QUALITY" "linux-snap-x64" package "$SNAP_FILENAME" "$VERSION" true "$SNAP_PATH" node build/azure-pipelines/common/publish.js "$VSCODE_QUALITY" "linux-snap-x64" package "$SNAP_FILENAME" "$VERSION" true "$SNAP_PATH"

View File

@@ -56,7 +56,7 @@ jobs:
- template: linux/snap-build-linux.yml - template: linux/snap-build-linux.yml
- job: LinuxArmhf - job: LinuxArmhf
condition: and(succeeded(), eq(variables['VSCODE_COMPILE_ONLY'], 'false'), eq(variables['VSCODE_BUILD_LINUX_ARMHF'], 'true'), ne(variables['VSCODE_QUALITY'], 'stable')) condition: and(succeeded(), eq(variables['VSCODE_COMPILE_ONLY'], 'false'), eq(variables['VSCODE_BUILD_LINUX_ARMHF'], 'true'))
pool: pool:
vmImage: 'Ubuntu-16.04' vmImage: 'Ubuntu-16.04'
variables: variables:
@@ -78,7 +78,7 @@ jobs:
- template: linux/product-build-linux-multiarch.yml - template: linux/product-build-linux-multiarch.yml
- job: LinuxAlpine - job: LinuxAlpine
condition: and(succeeded(), eq(variables['VSCODE_COMPILE_ONLY'], 'false'), eq(variables['VSCODE_BUILD_LINUX_ALPINE'], 'true'), ne(variables['VSCODE_QUALITY'], 'stable')) condition: and(succeeded(), eq(variables['VSCODE_COMPILE_ONLY'], 'false'), eq(variables['VSCODE_BUILD_LINUX_ALPINE'], 'true'))
pool: pool:
vmImage: 'Ubuntu-16.04' vmImage: 'Ubuntu-16.04'
variables: variables:

View File

@@ -20,7 +20,7 @@ steps:
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2 - task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
inputs: inputs:
versionSpec: "1.10.1" versionSpec: "1.x"
condition: and(succeeded(), ne(variables['CacheRestored-Compilation'], 'true')) condition: and(succeeded(), ne(variables['CacheRestored-Compilation'], 'true'))
- task: AzureKeyVault@1 - task: AzureKeyVault@1
@@ -87,9 +87,10 @@ steps:
- script: | - script: |
set -e set -e
yarn gulp hygiene yarn gulp hygiene --skip-tslint
yarn gulp tslint
yarn monaco-compile-check yarn monaco-compile-check
displayName: Run hygiene checks displayName: Run hygiene, tslint and monaco compile checks
condition: and(succeeded(), ne(variables['CacheRestored-Compilation'], 'true'), eq(variables['VSCODE_STEP_ON_IT'], 'false')) condition: and(succeeded(), ne(variables['CacheRestored-Compilation'], 'true'), eq(variables['VSCODE_STEP_ON_IT'], 'false'))
- script: | - script: |
@@ -98,6 +99,13 @@ steps:
displayName: Extract Telemetry displayName: Extract Telemetry
condition: and(succeeded(), ne(variables['CacheRestored-Compilation'], 'true')) condition: and(succeeded(), ne(variables['CacheRestored-Compilation'], 'true'))
- script: |
set -e
AZURE_WEBVIEW_STORAGE_ACCESS_KEY="$(vscode-webview-storage-key)" \
./build/azure-pipelines/common/publish-webview.sh
displayName: Publish Webview
condition: and(succeeded(), ne(variables['CacheRestored-Compilation'], 'true'))
- script: | - script: |
set -e set -e
yarn gulp compile-build yarn gulp compile-build

View File

@@ -13,7 +13,23 @@ steps:
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2 - task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
inputs: inputs:
versionSpec: "1.10.1" versionSpec: "1.x"
- bash: |
TAG_VERSION=$(git describe --tags `git rev-list --tags --max-count=1`)
CHANNEL="G1C14HJ2F"
if [ "$TAG_VERSION" == "1.999.0" ]; then
MESSAGE="<!here>. Someone pushed 1.999.0 tag. Please delete it ASAP from remote and local."
curl -X POST -H "Authorization: Bearer $(SLACK_TOKEN)" \
-H 'Content-type: application/json; charset=utf-8' \
--data '{"channel":"'"$CHANNEL"'", "link_names": true, "text":"'"$MESSAGE"'"}' \
https://slack.com/api/chat.postMessage
exit 1
fi
displayName: Check 1.999.0 tag
- bash: | - bash: |
# Install build dependencies # Install build dependencies

View File

@@ -5,7 +5,7 @@ steps:
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2 - task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
inputs: inputs:
versionSpec: "1.10.1" versionSpec: "1.x"
- task: AzureKeyVault@1 - task: AzureKeyVault@1
displayName: 'Azure Key Vault: Get Secrets' displayName: 'Azure Key Vault: Get Secrets'

View File

@@ -25,7 +25,7 @@ steps:
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2 - task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
inputs: inputs:
versionSpec: "1.10.1" versionSpec: "1.x"
- task: AzureKeyVault@1 - task: AzureKeyVault@1
displayName: 'Azure Key Vault: Get Secrets' displayName: 'Azure Key Vault: Get Secrets'

View File

@@ -4,7 +4,7 @@ steps:
versionSpec: "10.15.1" versionSpec: "10.15.1"
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2 - task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
inputs: inputs:
versionSpec: "1.10.1" versionSpec: "1.x"
- task: UsePythonVersion@0 - task: UsePythonVersion@0
inputs: inputs:
versionSpec: '2.x' versionSpec: '2.x'
@@ -26,10 +26,12 @@ steps:
condition: and(succeeded(), ne(variables['CacheRestored'], 'true')) condition: and(succeeded(), ne(variables['CacheRestored'], 'true'))
- powershell: | - powershell: |
yarn gulp electron yarn gulp electron
displayName: Download Electron - script: |
- powershell: | yarn gulp hygiene --skip-tslint
yarn gulp hygiene
displayName: Run Hygiene Checks displayName: Run Hygiene Checks
- script: |
yarn gulp tslint
displayName: Run TSLint Checks
- powershell: | - powershell: |
yarn monaco-compile-check yarn monaco-compile-check
displayName: Run Monaco Editor Checks displayName: Run Monaco Editor Checks

View File

@@ -25,7 +25,7 @@ steps:
- task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2 - task: geeklearningio.gl-vsts-tasks-yarn.yarn-installer-task.YarnInstaller@2
inputs: inputs:
versionSpec: "1.10.1" versionSpec: "1.x"
- task: UsePythonVersion@0 - task: UsePythonVersion@0
inputs: inputs:
@@ -113,10 +113,15 @@ steps:
condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false')) condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false'))
- powershell: | - powershell: |
# Figure out the full absolute path of the product we just built
# including the remote server and configure the integration tests
# to run with these builds instead of running out of sources.
. build/azure-pipelines/win32/exec.ps1 . build/azure-pipelines/win32/exec.ps1
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
exec { yarn gulp "electron-$(VSCODE_ARCH)" } $AppRoot = "$(agent.builddirectory)\VSCode-win32-$(VSCODE_ARCH)"
exec { .\scripts\test-integration.bat --build --tfs "Integration Tests" } $AppProductJson = Get-Content -Raw -Path "$AppRoot\resources\app\product.json" | ConvertFrom-Json
$AppNameShort = $AppProductJson.nameShort
exec { $env:INTEGRATION_TEST_ELECTRON_PATH = "$AppRoot\$AppNameShort.exe"; $env:VSCODE_REMOTE_SERVER_PATH = "$(agent.builddirectory)\vscode-reh-win32-$(VSCODE_ARCH)"; .\scripts\test-integration.bat --build --tfs "Integration Tests" }
displayName: Run integration tests displayName: Run integration tests
condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false')) condition: and(succeeded(), eq(variables['VSCODE_STEP_ON_IT'], 'false'))

View File

@@ -21,7 +21,6 @@ const nlsDev = require('vscode-nls-dev');
const root = path.dirname(__dirname); const root = path.dirname(__dirname);
const commit = util.getVersion(root); const commit = util.getVersion(root);
const plumber = require('gulp-plumber'); const plumber = require('gulp-plumber');
const _ = require('underscore');
const ext = require('./lib/extensions'); const ext = require('./lib/extensions');
const extensionsPath = path.join(path.dirname(__dirname), 'extensions'); const extensionsPath = path.join(path.dirname(__dirname), 'extensions');
@@ -37,16 +36,16 @@ const tasks = compilations.map(function (tsconfigFile) {
const absolutePath = path.join(extensionsPath, tsconfigFile); const absolutePath = path.join(extensionsPath, tsconfigFile);
const relativeDirname = path.dirname(tsconfigFile); const relativeDirname = path.dirname(tsconfigFile);
const tsconfig = require(absolutePath); const overrideOptions = {};
const tsOptions = _.assign({}, tsconfig.extends ? require(path.join(extensionsPath, relativeDirname, tsconfig.extends)).compilerOptions : {}, tsconfig.compilerOptions); overrideOptions.sourceMap = true;
tsOptions.verbose = false;
tsOptions.sourceMap = true;
const name = relativeDirname.replace(/\//g, '-'); const name = relativeDirname.replace(/\//g, '-');
const root = path.join('extensions', relativeDirname); const root = path.join('extensions', relativeDirname);
const srcBase = path.join(root, 'src'); const srcBase = path.join(root, 'src');
const src = path.join(srcBase, '**'); const src = path.join(srcBase, '**');
const srcOpts = { cwd: path.dirname(__dirname), base: srcBase };
const out = path.join(root, 'out'); const out = path.join(root, 'out');
const baseUrl = getBaseUrl(out); const baseUrl = getBaseUrl(out);
@@ -63,12 +62,12 @@ const tasks = compilations.map(function (tsconfigFile) {
function createPipeline(build, emitError) { function createPipeline(build, emitError) {
const reporter = createReporter(); const reporter = createReporter();
tsOptions.inlineSources = !!build; overrideOptions.inlineSources = Boolean(build);
tsOptions.base = path.dirname(absolutePath); overrideOptions.base = path.dirname(absolutePath);
const compilation = tsb.create(tsOptions, null, null, err => reporter(err.toString())); const compilation = tsb.create(absolutePath, overrideOptions, false, err => reporter(err.toString()));
return function () { const pipeline = function () {
const input = es.through(); const input = es.through();
const tsFilter = filter(['**/*.ts', '!**/lib/lib*.d.ts', '!**/node_modules/**'], { restore: true }); const tsFilter = filter(['**/*.ts', '!**/lib/lib*.d.ts', '!**/node_modules/**'], { restore: true });
const output = input const output = input
@@ -98,15 +97,19 @@ const tasks = compilations.map(function (tsconfigFile) {
return es.duplex(input, output); return es.duplex(input, output);
}; };
}
const srcOpts = { cwd: path.dirname(__dirname), base: srcBase }; // add src-stream for project files
pipeline.tsProjectSrc = () => {
return compilation.src(srcOpts);
};
return pipeline;
}
const cleanTask = task.define(`clean-extension-${name}`, util.rimraf(out)); const cleanTask = task.define(`clean-extension-${name}`, util.rimraf(out));
const compileTask = task.define(`compile-extension:${name}`, task.series(cleanTask, () => { const compileTask = task.define(`compile-extension:${name}`, task.series(cleanTask, () => {
const pipeline = createPipeline(false, true); const pipeline = createPipeline(false, true);
const input = gulp.src(src, srcOpts); const input = pipeline.tsProjectSrc();
return input return input
.pipe(pipeline()) .pipe(pipeline())
@@ -115,8 +118,8 @@ const tasks = compilations.map(function (tsconfigFile) {
const watchTask = task.define(`watch-extension:${name}`, task.series(cleanTask, () => { const watchTask = task.define(`watch-extension:${name}`, task.series(cleanTask, () => {
const pipeline = createPipeline(false); const pipeline = createPipeline(false);
const input = gulp.src(src, srcOpts); const input = pipeline.tsProjectSrc();
const watchInput = watcher(src, srcOpts); const watchInput = watcher(src, { ...srcOpts, ...{ readDelay: 200 } });
return watchInput return watchInput
.pipe(util.incremental(pipeline, input)) .pipe(util.incremental(pipeline, input))
@@ -125,7 +128,7 @@ const tasks = compilations.map(function (tsconfigFile) {
const compileBuildTask = task.define(`compile-build-extension-${name}`, task.series(cleanTask, () => { const compileBuildTask = task.define(`compile-build-extension-${name}`, task.series(cleanTask, () => {
const pipeline = createPipeline(true, true); const pipeline = createPipeline(true, true);
const input = gulp.src(src, srcOpts); const input = pipeline.tsProjectSrc();
return input return input
.pipe(pipeline()) .pipe(pipeline())
@@ -156,8 +159,8 @@ const cleanExtensionsBuildTask = task.define('clean-extensions-build', util.rimr
const compileExtensionsBuildTask = task.define('compile-extensions-build', task.series( const compileExtensionsBuildTask = task.define('compile-extensions-build', task.series(
cleanExtensionsBuildTask, cleanExtensionsBuildTask,
task.define('bundle-extensions-build', () => ext.packageLocalExtensionsStream().pipe(gulp.dest('.build'))), task.define('bundle-extensions-build', () => ext.packageLocalExtensionsStream().pipe(gulp.dest('.build'))),
task.define('bundle-marketplace-extensions-build', () => ext.packageMarketplaceExtensionsStream().pipe(gulp.dest('.build'))), task.define('bundle-marketplace-extensions-build', () => ext.packageMarketplaceExtensionsStream().pipe(gulp.dest('.build')))
)); ));
gulp.task(compileExtensionsBuildTask); gulp.task(compileExtensionsBuildTask);
exports.compileExtensionsBuildTask = compileExtensionsBuildTask; exports.compileExtensionsBuildTask = compileExtensionsBuildTask;

View File

@@ -17,6 +17,7 @@ const vfs = require('vinyl-fs');
const path = require('path'); const path = require('path');
const fs = require('fs'); const fs = require('fs');
const pall = require('p-all'); const pall = require('p-all');
const task = require('./lib/task');
/** /**
* Hygiene works by creating cascading subsets of all our files and * Hygiene works by creating cascading subsets of all our files and
@@ -57,6 +58,7 @@ const indentationFilter = [
'!test/assert.js', '!test/assert.js',
// except specific folders // except specific folders
'!test/automation/out/**',
'!test/smoke/out/**', '!test/smoke/out/**',
'!extensions/vscode-api-tests/testWorkspace/**', '!extensions/vscode-api-tests/testWorkspace/**',
'!extensions/vscode-api-tests/testWorkspace2/**', '!extensions/vscode-api-tests/testWorkspace2/**',
@@ -192,13 +194,13 @@ const tslintBaseFilter = [
]; ];
// {{SQL CARBON EDIT}} // {{SQL CARBON EDIT}}
const useStrictFilter = [ // const useStrictFilter = [
'src/**' // 'src/**'
]; // ];
const sqlFilter = [ // const sqlFilter = [
'src/sql/**' // 'src/sql/**'
]; // ];
// {{SQL CARBON EDIT}} // {{SQL CARBON EDIT}}
@@ -206,6 +208,7 @@ const tslintCoreFilter = [
'src/**/*.ts', 'src/**/*.ts',
'test/**/*.ts', 'test/**/*.ts',
'!extensions/**/*.ts', '!extensions/**/*.ts',
'!test/automation/**',
'!test/smoke/**', '!test/smoke/**',
...tslintBaseFilter ...tslintBaseFilter
]; ];
@@ -214,6 +217,7 @@ const tslintExtensionsFilter = [
'extensions/**/*.ts', 'extensions/**/*.ts',
'!src/**/*.ts', '!src/**/*.ts',
'!test/**/*.ts', '!test/**/*.ts',
'test/automation/**/*.ts',
...tslintBaseFilter ...tslintBaseFilter
]; ];
@@ -256,6 +260,33 @@ gulp.task('tslint', () => {
]).pipe(es.through()); ]).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) { function hygiene(some) {
let errorCount = 0; let errorCount = 0;
@@ -307,19 +338,19 @@ function hygiene(some) {
// {{SQL CARBON EDIT}} // {{SQL CARBON EDIT}}
// Check for unnecessary 'use strict' lines. These are automatically added by the alwaysStrict compiler option so don't need to be added manually // Check for unnecessary 'use strict' lines. These are automatically added by the alwaysStrict compiler option so don't need to be added manually
const useStrict = es.through(function (file) { // const useStrict = es.through(function (file) {
const lines = file.__lines; // const lines = file.__lines;
// Only take the first 10 lines to reduce false positives- the compiler will throw an error if it's not the first non-comment line in a file // // Only take the first 10 lines to reduce false positives- the compiler will throw an error if it's not the first non-comment line in a file
// (10 is used to account for copyright and extraneous newlines) // // (10 is used to account for copyright and extraneous newlines)
lines.slice(0, 10).forEach((line, i) => { // lines.slice(0, 10).forEach((line, i) => {
if (/\s*'use\s*strict\s*'/.test(line)) { // if (/\s*'use\s*strict\s*'/.test(line)) {
console.error(file.relative + '(' + (i + 1) + ',1): Unnecessary \'use strict\' - this is already added by the compiler'); // console.error(file.relative + '(' + (i + 1) + ',1): Unnecessary \'use strict\' - this is already added by the compiler');
errorCount++; // errorCount++;
} // }
}); // });
this.emit('data', file); // this.emit('data', file);
}); // });
// {{SQL CARBON EDIT}} END // {{SQL CARBON EDIT}} END
const formatting = es.map(function (file, cb) { const formatting = es.map(function (file, cb) {
@@ -370,16 +401,16 @@ function hygiene(some) {
input = some; input = some;
} }
const tslintSqlConfiguration = tslint.Configuration.findConfiguration('tslint-sql.json', '.'); // const tslintSqlConfiguration = tslint.Configuration.findConfiguration('tslint-sql.json', '.'); // TODO RESTORE
const tslintSqlOptions = { fix: false, formatter: 'json' }; const tslintSqlOptions = { fix: false, formatter: 'json' };
const sqlTsLinter = new tslint.Linter(tslintSqlOptions); const sqlTsLinter = new tslint.Linter(tslintSqlOptions);
const sqlTsl = es.through(function (file) { // const sqlTsl = es.through(function (file) { //TODO restore
const contents = file.contents.toString('utf8'); // const contents = file.contents.toString('utf8');
sqlTsLinter.lint(file.relative, contents, tslintSqlConfiguration.results); // sqlTsLinter.lint(file.relative, contents, tslintSqlConfiguration.results);
this.emit('data', file); // this.emit('data', file);
}); // });
const productJsonFilter = filter('product.json', { restore: true }); const productJsonFilter = filter('product.json', { restore: true });
@@ -393,15 +424,13 @@ function hygiene(some) {
.pipe(filter(copyrightFilter)) .pipe(filter(copyrightFilter))
.pipe(copyrights); .pipe(copyrights);
const typescript = result let typescript = result
.pipe(filter(tslintHygieneFilter)) .pipe(filter(tslintHygieneFilter))
.pipe(formatting) .pipe(formatting);
.pipe(tsl)
// {{SQL CARBON EDIT}} if (!process.argv.some(arg => arg === '--skip-tslint')) {
.pipe(filter(useStrictFilter)) typescript = typescript.pipe(tsl);
.pipe(useStrict) }
.pipe(filter(sqlFilter))
.pipe(sqlTsl);
const javascript = result const javascript = result
.pipe(filter(eslintFilter)) .pipe(filter(eslintFilter))
@@ -487,7 +516,7 @@ function createGitIndexVinyls(paths) {
.then(r => r.filter(p => !!p)); .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 // this allows us to run hygiene as a git pre-commit hook
if (require.main === module) { if (require.main === module) {

View File

@@ -60,8 +60,7 @@ const nodeModules = [
const vscodeEntryPoints = _.flatten([ const vscodeEntryPoints = _.flatten([
buildfile.entrypoint('vs/workbench/workbench.desktop.main'), buildfile.entrypoint('vs/workbench/workbench.desktop.main'),
buildfile.base, buildfile.base,
buildfile.serviceWorker, buildfile.workbenchDesktop,
buildfile.workbench,
buildfile.code buildfile.code
]); ]);
@@ -125,6 +124,7 @@ const optimizeVSCodeTask = task.define('optimize-vscode', task.series(
resources: vscodeResources, resources: vscodeResources,
loaderConfig: common.loaderConfig(nodeModules), loaderConfig: common.loaderConfig(nodeModules),
out: 'out-vscode', out: 'out-vscode',
inlineAmdImages: true,
bundleInfo: undefined bundleInfo: undefined
}) })
)); ));
@@ -468,7 +468,7 @@ gulp.task(task.define(
optimizeVSCodeTask, optimizeVSCodeTask,
function () { function () {
const pathToMetadata = './out-vscode/nls.metadata.json'; const pathToMetadata = './out-vscode/nls.metadata.json';
const pathToExtensions = './extensions/*'; const pathToExtensions = '.build/extensions/*';
const pathToSetup = 'build/win32/**/{Default.isl,messages.en.isl}'; const pathToSetup = 'build/win32/**/{Default.isl,messages.en.isl}';
return es.merge( return es.merge(
@@ -489,7 +489,7 @@ gulp.task(task.define(
optimizeVSCodeTask, optimizeVSCodeTask,
function () { function () {
const pathToMetadata = './out-vscode/nls.metadata.json'; const pathToMetadata = './out-vscode/nls.metadata.json';
const pathToExtensions = './extensions/*'; const pathToExtensions = '.build/extensions/*';
const pathToSetup = 'build/win32/**/{Default.isl,messages.en.isl}'; const pathToSetup = 'build/win32/**/{Default.isl,messages.en.isl}';
return es.merge( return es.merge(

View File

@@ -43,6 +43,7 @@ function prepareDebPackage(arch) {
.pipe(replace('@@NAME_LONG@@', product.nameLong)) .pipe(replace('@@NAME_LONG@@', product.nameLong))
.pipe(replace('@@NAME_SHORT@@', product.nameShort)) .pipe(replace('@@NAME_SHORT@@', product.nameShort))
.pipe(replace('@@NAME@@', product.applicationName)) .pipe(replace('@@NAME@@', product.applicationName))
.pipe(replace('@@EXEC@@', `/usr/share/${product.applicationName}/${product.applicationName}`))
.pipe(replace('@@ICON@@', product.linuxIconName)) .pipe(replace('@@ICON@@', product.linuxIconName))
.pipe(replace('@@URLPROTOCOL@@', product.urlProtocol)); .pipe(replace('@@URLPROTOCOL@@', product.urlProtocol));
@@ -136,6 +137,7 @@ function prepareRpmPackage(arch) {
.pipe(replace('@@NAME_LONG@@', product.nameLong)) .pipe(replace('@@NAME_LONG@@', product.nameLong))
.pipe(replace('@@NAME_SHORT@@', product.nameShort)) .pipe(replace('@@NAME_SHORT@@', product.nameShort))
.pipe(replace('@@NAME@@', product.applicationName)) .pipe(replace('@@NAME@@', product.applicationName))
.pipe(replace('@@EXEC@@', `/usr/share/${product.applicationName}/${product.applicationName}`))
.pipe(replace('@@ICON@@', product.linuxIconName)) .pipe(replace('@@ICON@@', product.linuxIconName))
.pipe(replace('@@URLPROTOCOL@@', product.urlProtocol)); .pipe(replace('@@URLPROTOCOL@@', product.urlProtocol));
@@ -206,21 +208,25 @@ function prepareSnapPackage(arch) {
const destination = getSnapBuildPath(arch); const destination = getSnapBuildPath(arch);
return function () { return function () {
// A desktop file that is placed in snap/gui will be placed into meta/gui verbatim.
const desktop = gulp.src('resources/linux/code.desktop', { base: '.' }) const desktop = gulp.src('resources/linux/code.desktop', { base: '.' })
.pipe(rename(`usr/share/applications/${product.applicationName}.desktop`)); .pipe(rename(`snap/gui/${product.applicationName}.desktop`));
// A desktop file that is placed in snap/gui will be placed into meta/gui verbatim.
const desktopUrlHandler = gulp.src('resources/linux/code-url-handler.desktop', { base: '.' }) const desktopUrlHandler = gulp.src('resources/linux/code-url-handler.desktop', { base: '.' })
.pipe(rename(`usr/share/applications/${product.applicationName}-url-handler.desktop`)); .pipe(rename(`snap/gui/${product.applicationName}-url-handler.desktop`));
const desktops = es.merge(desktop, desktopUrlHandler) const desktops = es.merge(desktop, desktopUrlHandler)
.pipe(replace('@@NAME_LONG@@', product.nameLong)) .pipe(replace('@@NAME_LONG@@', product.nameLong))
.pipe(replace('@@NAME_SHORT@@', product.nameShort)) .pipe(replace('@@NAME_SHORT@@', product.nameShort))
.pipe(replace('@@NAME@@', product.applicationName)) .pipe(replace('@@NAME@@', product.applicationName))
.pipe(replace('@@ICON@@', `/usr/share/pixmaps/${product.linuxIconName}.png`)) .pipe(replace('@@EXEC@@', `${product.applicationName} --force-user-env`))
.pipe(replace('@@ICON@@', `\${SNAP}/meta/gui/${product.linuxIconName}.png`))
.pipe(replace('@@URLPROTOCOL@@', product.urlProtocol)); .pipe(replace('@@URLPROTOCOL@@', product.urlProtocol));
// An icon that is placed in snap/gui will be placed into meta/gui verbatim.
const icon = gulp.src('resources/linux/code.png', { base: '.' }) const icon = gulp.src('resources/linux/code.png', { base: '.' })
.pipe(rename(`usr/share/pixmaps/${product.linuxIconName}.png`)); .pipe(rename(`snap/gui/${product.linuxIconName}.png`));
const code = gulp.src(binaryDir + '/**/*', { base: binaryDir }) const code = gulp.src(binaryDir + '/**/*', { base: binaryDir })
.pipe(rename(function (p) { p.dirname = `usr/share/${product.applicationName}/${p.dirname}`; })); .pipe(rename(function (p) { p.dirname = `usr/share/${product.applicationName}/${p.dirname}`; }));
@@ -241,7 +247,8 @@ function prepareSnapPackage(arch) {
function buildSnapPackage(arch) { function buildSnapPackage(arch) {
const snapBuildPath = getSnapBuildPath(arch); const snapBuildPath = getSnapBuildPath(arch);
return shell.task(`cd ${snapBuildPath} && snapcraft build`); // Default target for snapcraft runs: pull, build, stage and prime, and finally assembles the snap.
return shell.task(`cd ${snapBuildPath} && snapcraft`);
} }
const BUILD_TARGETS = [ const BUILD_TARGETS = [

View File

@@ -6,150 +6,11 @@
'use strict'; 'use strict';
const gulp = require('gulp'); 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 noop = () => { return Promise.resolve(); };
const commit = util.getVersion(REPO_ROOT);
const BUILD_ROOT = path.dirname(REPO_ROOT);
const WEB_FOLDER = path.join(REPO_ROOT, 'remote', 'web');
const productionDependencies = deps.getProductionDependencies(WEB_FOLDER); gulp.task('minify-vscode-web', noop);
gulp.task('vscode-web', noop);
const nodeModules = Object.keys(product.dependencies || {}) gulp.task('vscode-web-min', noop);
.concat(_.uniq(productionDependencies.map(d => d.name))); gulp.task('vscode-web-ci', noop);
gulp.task('vscode-web-min-ci', noop);
const vscodeWebResources = [
// Workbench
'out-build/vs/{base,platform,editor,workbench}/**/*.{svg,png,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 = [
buildfile.workbenchWeb,
buildfile.serviceWorker,
buildfile.workerExtensionHost,
buildfile.keyboardMaps,
buildfile.base
];
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' });
let all = es.merge(
packageJsonStream,
productJsonStream,
license,
sources,
deps,
favicon
);
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);
});

View File

@@ -11,7 +11,6 @@ const bom = require("gulp-bom");
const sourcemaps = require("gulp-sourcemaps"); const sourcemaps = require("gulp-sourcemaps");
const tsb = require("gulp-tsb"); const tsb = require("gulp-tsb");
const path = require("path"); const path = require("path");
const _ = require("underscore");
const monacodts = require("../monaco/api"); const monacodts = require("../monaco/api");
const nls = require("./nls"); const nls = require("./nls");
const reporter_1 = require("./reporter"); const reporter_1 = require("./reporter");
@@ -22,14 +21,7 @@ const watch = require('./watch');
const reporter = reporter_1.createReporter(); const reporter = reporter_1.createReporter();
function getTypeScriptCompilerOptions(src) { function getTypeScriptCompilerOptions(src) {
const rootDir = path.join(__dirname, `../../${src}`); const rootDir = path.join(__dirname, `../../${src}`);
const tsconfig = require(`../../${src}/tsconfig.json`); let options = {};
let options;
if (tsconfig.extends) {
options = Object.assign({}, require(path.join(rootDir, tsconfig.extends)).compilerOptions, tsconfig.compilerOptions);
}
else {
options = tsconfig.compilerOptions;
}
options.verbose = false; options.verbose = false;
options.sourceMap = true; options.sourceMap = true;
if (process.env['VSCODE_NO_SOURCEMAP']) { // To be used by developers in a hurry if (process.env['VSCODE_NO_SOURCEMAP']) { // To be used by developers in a hurry
@@ -38,15 +30,14 @@ function getTypeScriptCompilerOptions(src) {
options.rootDir = rootDir; options.rootDir = rootDir;
options.baseUrl = rootDir; options.baseUrl = rootDir;
options.sourceRoot = util.toFileUri(rootDir); options.sourceRoot = util.toFileUri(rootDir);
options.newLine = /\r\n/.test(fs.readFileSync(__filename, 'utf8')) ? 'CRLF' : 'LF'; options.newLine = /\r\n/.test(fs.readFileSync(__filename, 'utf8')) ? 0 : 1;
return options; return options;
} }
function createCompile(src, build, emitError) { function createCompile(src, build, emitError) {
const opts = _.clone(getTypeScriptCompilerOptions(src)); const projectPath = path.join(__dirname, '../../', src, 'tsconfig.json');
opts.inlineSources = !!build; const overrideOptions = Object.assign(Object.assign({}, getTypeScriptCompilerOptions(src)), { inlineSources: Boolean(build) });
opts.noFilesystemLookup = true; const compilation = tsb.create(projectPath, overrideOptions, false, err => reporter(err));
const ts = tsb.create(opts, true, undefined, err => reporter(err.toString())); function pipeline(token) {
return function (token) {
const utf8Filter = util.filter(data => /(\/|\\)test(\/|\\).*utf8/.test(data.path)); const utf8Filter = util.filter(data => /(\/|\\)test(\/|\\).*utf8/.test(data.path));
const tsFilter = util.filter(data => /\.ts$/.test(data.path)); const tsFilter = util.filter(data => /\.ts$/.test(data.path));
const noDeclarationsFilter = util.filter(data => !(/\.d\.ts$/.test(data.path))); const noDeclarationsFilter = util.filter(data => !(/\.d\.ts$/.test(data.path)));
@@ -57,30 +48,28 @@ function createCompile(src, build, emitError) {
.pipe(utf8Filter.restore) .pipe(utf8Filter.restore)
.pipe(tsFilter) .pipe(tsFilter)
.pipe(util.loadSourcemaps()) .pipe(util.loadSourcemaps())
.pipe(ts(token)) .pipe(compilation(token))
.pipe(noDeclarationsFilter) .pipe(noDeclarationsFilter)
.pipe(build ? nls() : es.through()) .pipe(build ? nls() : es.through())
.pipe(noDeclarationsFilter.restore) .pipe(noDeclarationsFilter.restore)
.pipe(sourcemaps.write('.', { .pipe(sourcemaps.write('.', {
addComment: false, addComment: false,
includeContent: !!build, includeContent: !!build,
sourceRoot: opts.sourceRoot sourceRoot: overrideOptions.sourceRoot
})) }))
.pipe(tsFilter.restore) .pipe(tsFilter.restore)
.pipe(reporter.end(!!emitError)); .pipe(reporter.end(!!emitError));
return es.duplex(input, output); return es.duplex(input, output);
}
pipeline.tsProjectSrc = () => {
return compilation.src({ base: src });
}; };
return pipeline;
} }
const typesDts = [
'node_modules/typescript/lib/*.d.ts',
'node_modules/@types/**/*.d.ts',
'!node_modules/@types/webpack/**/*',
'!node_modules/@types/uglify-js/**/*',
];
function compileTask(src, out, build) { function compileTask(src, out, build) {
return function () { return function () {
const compile = createCompile(src, build, true); const compile = createCompile(src, build, true);
const srcPipe = es.merge(gulp.src(`${src}/**`, { base: `${src}` }), gulp.src(typesDts)); const srcPipe = gulp.src(`${src}/**`, { base: `${src}` });
let generator = new MonacoGenerator(false); let generator = new MonacoGenerator(false);
if (src === 'src') { if (src === 'src') {
generator.execute(); generator.execute();
@@ -95,8 +84,8 @@ exports.compileTask = compileTask;
function watchTask(out, build) { function watchTask(out, build) {
return function () { return function () {
const compile = createCompile('src', build); const compile = createCompile('src', build);
const src = es.merge(gulp.src('src/**', { base: 'src' }), gulp.src(typesDts)); const src = gulp.src('src/**', { base: 'src' });
const watchSrc = watch('src/**', { base: 'src' }); const watchSrc = watch('src/**', { base: 'src', readDelay: 200 });
let generator = new MonacoGenerator(true); let generator = new MonacoGenerator(true);
generator.execute(); generator.execute();
return watchSrc return watchSrc

View File

@@ -12,27 +12,21 @@ import * as bom from 'gulp-bom';
import * as sourcemaps from 'gulp-sourcemaps'; import * as sourcemaps from 'gulp-sourcemaps';
import * as tsb from 'gulp-tsb'; import * as tsb from 'gulp-tsb';
import * as path from 'path'; import * as path from 'path';
import * as _ from 'underscore';
import * as monacodts from '../monaco/api'; import * as monacodts from '../monaco/api';
import * as nls from './nls'; import * as nls from './nls';
import { createReporter } from './reporter'; import { createReporter } from './reporter';
import * as util from './util'; import * as util from './util';
import * as fancyLog from 'fancy-log'; import * as fancyLog from 'fancy-log';
import * as ansiColors from 'ansi-colors'; import * as ansiColors from 'ansi-colors';
import ts = require('typescript');
const watch = require('./watch'); const watch = require('./watch');
const reporter = createReporter(); const reporter = createReporter();
function getTypeScriptCompilerOptions(src: string) { function getTypeScriptCompilerOptions(src: string): ts.CompilerOptions {
const rootDir = path.join(__dirname, `../../${src}`); const rootDir = path.join(__dirname, `../../${src}`);
const tsconfig = require(`../../${src}/tsconfig.json`); let options: ts.CompilerOptions = {};
let options: { [key: string]: any };
if (tsconfig.extends) {
options = Object.assign({}, require(path.join(rootDir, tsconfig.extends)).compilerOptions, tsconfig.compilerOptions);
} else {
options = tsconfig.compilerOptions;
}
options.verbose = false; options.verbose = false;
options.sourceMap = true; options.sourceMap = true;
if (process.env['VSCODE_NO_SOURCEMAP']) { // To be used by developers in a hurry if (process.env['VSCODE_NO_SOURCEMAP']) { // To be used by developers in a hurry
@@ -41,18 +35,17 @@ function getTypeScriptCompilerOptions(src: string) {
options.rootDir = rootDir; options.rootDir = rootDir;
options.baseUrl = rootDir; options.baseUrl = rootDir;
options.sourceRoot = util.toFileUri(rootDir); options.sourceRoot = util.toFileUri(rootDir);
options.newLine = /\r\n/.test(fs.readFileSync(__filename, 'utf8')) ? 'CRLF' : 'LF'; options.newLine = /\r\n/.test(fs.readFileSync(__filename, 'utf8')) ? 0 : 1;
return options; return options;
} }
function createCompile(src: string, build: boolean, emitError?: boolean): (token?: util.ICancellationToken) => NodeJS.ReadWriteStream { function createCompile(src: string, build: boolean, emitError?: boolean) {
const opts = _.clone(getTypeScriptCompilerOptions(src)); const projectPath = path.join(__dirname, '../../', src, 'tsconfig.json');
opts.inlineSources = !!build; const overrideOptions = { ...getTypeScriptCompilerOptions(src), inlineSources: Boolean(build) };
opts.noFilesystemLookup = true;
const ts = tsb.create(opts, true, undefined, err => reporter(err.toString())); const compilation = tsb.create(projectPath, overrideOptions, false, err => reporter(err));
return function (token?: util.ICancellationToken) { function pipeline(token?: util.ICancellationToken) {
const utf8Filter = util.filter(data => /(\/|\\)test(\/|\\).*utf8/.test(data.path)); const utf8Filter = util.filter(data => /(\/|\\)test(\/|\\).*utf8/.test(data.path));
const tsFilter = util.filter(data => /\.ts$/.test(data.path)); const tsFilter = util.filter(data => /\.ts$/.test(data.path));
@@ -65,39 +58,31 @@ function createCompile(src: string, build: boolean, emitError?: boolean): (token
.pipe(utf8Filter.restore) .pipe(utf8Filter.restore)
.pipe(tsFilter) .pipe(tsFilter)
.pipe(util.loadSourcemaps()) .pipe(util.loadSourcemaps())
.pipe(ts(token)) .pipe(compilation(token))
.pipe(noDeclarationsFilter) .pipe(noDeclarationsFilter)
.pipe(build ? nls() : es.through()) .pipe(build ? nls() : es.through())
.pipe(noDeclarationsFilter.restore) .pipe(noDeclarationsFilter.restore)
.pipe(sourcemaps.write('.', { .pipe(sourcemaps.write('.', {
addComment: false, addComment: false,
includeContent: !!build, includeContent: !!build,
sourceRoot: opts.sourceRoot sourceRoot: overrideOptions.sourceRoot
})) }))
.pipe(tsFilter.restore) .pipe(tsFilter.restore)
.pipe(reporter.end(!!emitError)); .pipe(reporter.end(!!emitError));
return es.duplex(input, output); return es.duplex(input, output);
}
pipeline.tsProjectSrc = () => {
return compilation.src({ base: src });
}; };
return pipeline;
} }
const typesDts = [
'node_modules/typescript/lib/*.d.ts',
'node_modules/@types/**/*.d.ts',
'!node_modules/@types/webpack/**/*',
'!node_modules/@types/uglify-js/**/*',
];
export function compileTask(src: string, out: string, build: boolean): () => NodeJS.ReadWriteStream { export function compileTask(src: string, out: string, build: boolean): () => NodeJS.ReadWriteStream {
return function () { return function () {
const compile = createCompile(src, build, true); const compile = createCompile(src, build, true);
const srcPipe = gulp.src(`${src}/**`, { base: `${src}` });
const srcPipe = es.merge(
gulp.src(`${src}/**`, { base: `${src}` }),
gulp.src(typesDts),
);
let generator = new MonacoGenerator(false); let generator = new MonacoGenerator(false);
if (src === 'src') { if (src === 'src') {
generator.execute(); generator.execute();
@@ -115,11 +100,8 @@ export function watchTask(out: string, build: boolean): () => NodeJS.ReadWriteSt
return function () { return function () {
const compile = createCompile('src', build); const compile = createCompile('src', build);
const src = es.merge( const src = gulp.src('src/**', { base: 'src' });
gulp.src('src/**', { base: 'src' }), const watchSrc = watch('src/**', { base: 'src', readDelay: 200 });
gulp.src(typesDts),
);
const watchSrc = watch('src/**', { base: 'src' });
let generator = new MonacoGenerator(true); let generator = new MonacoGenerator(true);
generator.execute(); generator.execute();

View File

@@ -101,7 +101,7 @@ function fromLocalWebpack(extensionPath) {
result.emit('error', compilation.warnings.join('\n')); result.emit('error', compilation.warnings.join('\n'));
} }
}; };
const webpackConfig = Object.assign({}, require(webpackConfigPath), { mode: 'production' }); const webpackConfig = Object.assign(Object.assign({}, require(webpackConfigPath)), { mode: 'production' });
const relativeOutputPath = path.relative(extensionPath, webpackConfig.output.path); const relativeOutputPath = path.relative(extensionPath, webpackConfig.output.path);
return webpackGulp(webpackConfig, webpack, webpackDone) return webpackGulp(webpackConfig, webpack, webpackDone)
.pipe(es.through(function (data) { .pipe(es.through(function (data) {

View File

@@ -176,6 +176,7 @@ class XLF {
this.buffer.push(line.toString()); this.buffer.push(line.toString());
} }
} }
exports.XLF = XLF;
XLF.parsePseudo = function (xlfString) { XLF.parsePseudo = function (xlfString) {
return new Promise((resolve) => { return new Promise((resolve) => {
let parser = new xml2js.Parser(); let parser = new xml2js.Parser();
@@ -248,7 +249,6 @@ XLF.parse = function (xlfString) {
}); });
}); });
}; };
exports.XLF = XLF;
class Limiter { class Limiter {
constructor(maxDegreeOfParalellism) { constructor(maxDegreeOfParalellism) {
this.maxDegreeOfParalellism = maxDegreeOfParalellism; this.maxDegreeOfParalellism = maxDegreeOfParalellism;
@@ -586,7 +586,7 @@ function createXlfFilesForExtensions() {
} }
return _xlf; return _xlf;
} }
gulp.src([`./extensions/${extensionName}/package.nls.json`, `./extensions/${extensionName}/**/nls.metadata.json`], { allowEmpty: true }).pipe(event_stream_1.through(function (file) { gulp.src([`.build/extensions/${extensionName}/package.nls.json`, `.build/extensions/${extensionName}/**/nls.metadata.json`], { allowEmpty: true }).pipe(event_stream_1.through(function (file) {
if (file.isBuffer()) { if (file.isBuffer()) {
const buffer = file.contents; const buffer = file.contents;
const basename = path.basename(file.path); const basename = path.basename(file.path);
@@ -609,7 +609,7 @@ function createXlfFilesForExtensions() {
} }
else if (basename === 'nls.metadata.json') { else if (basename === 'nls.metadata.json') {
const json = JSON.parse(buffer.toString('utf8')); const json = JSON.parse(buffer.toString('utf8'));
const relPath = path.relative(`./extensions/${extensionName}`, path.dirname(file.path)); const relPath = path.relative(`.build/extensions/${extensionName}`, path.dirname(file.path));
for (let file in json) { for (let file in json) {
const fileContent = json[file]; const fileContent = json[file];
getXlf().addFile(`extensions/${extensionName}/${relPath}/${file}`, fileContent.keys, fileContent.messages); getXlf().addFile(`extensions/${extensionName}/${relPath}/${file}`, fileContent.keys, fileContent.messages);
@@ -912,8 +912,8 @@ function pullCoreAndExtensionsXlfFiles(apiHostname, username, password, language
_coreAndExtensionResources.push(...json.workbench); _coreAndExtensionResources.push(...json.workbench);
// extensions // extensions
let extensionsToLocalize = Object.create(null); let extensionsToLocalize = Object.create(null);
glob.sync('./extensions/**/*.nls.json').forEach(extension => extensionsToLocalize[extension.split('/')[2]] = true); glob.sync('.build/extensions/**/*.nls.json').forEach(extension => extensionsToLocalize[extension.split('/')[2]] = true);
glob.sync('./extensions/*/node_modules/vscode-nls').forEach(extension => extensionsToLocalize[extension.split('/')[2]] = true); glob.sync('.build/extensions/*/node_modules/vscode-nls').forEach(extension => extensionsToLocalize[extension.split('/')[2]] = true);
Object.keys(extensionsToLocalize).forEach(extension => { Object.keys(extensionsToLocalize).forEach(extension => {
_coreAndExtensionResources.push({ name: extension, project: extensionsProject }); _coreAndExtensionResources.push({ name: extension, project: extensionsProject });
}); });
@@ -1086,7 +1086,7 @@ function prepareI18nPackFiles(externalExtensions, resultingTranslationPaths, pse
resultingTranslationPaths.push({ id: 'vscode', resourceName: 'main.i18n.json' }); resultingTranslationPaths.push({ id: 'vscode', resourceName: 'main.i18n.json' });
this.queue(translatedMainFile); this.queue(translatedMainFile);
for (let extension in extensionsPacks) { for (let extension in extensionsPacks) {
const translatedExtFile = createI18nFile(`./extensions/${extension}`, extensionsPacks[extension]); const translatedExtFile = createI18nFile(`.build/extensions/${extension}`, extensionsPacks[extension]);
this.queue(translatedExtFile); this.queue(translatedExtFile);
const externalExtensionId = externalExtensions[extension]; const externalExtensionId = externalExtensions[extension];
if (externalExtensionId) { if (externalExtensionId) {

View File

@@ -170,6 +170,10 @@
"name": "vs/workbench/contrib/webview", "name": "vs/workbench/contrib/webview",
"project": "vscode-workbench" "project": "vscode-workbench"
}, },
{
"name": "vs/workbench/contrib/customEditor",
"project": "vscode-workbench"
},
{ {
"name": "vs/workbench/contrib/welcome", "name": "vs/workbench/contrib/welcome",
"project": "vscode-workbench" "project": "vscode-workbench"

View File

@@ -709,7 +709,7 @@ export function createXlfFilesForExtensions(): ThroughStream {
} }
return _xlf; return _xlf;
} }
gulp.src([`./extensions/${extensionName}/package.nls.json`, `./extensions/${extensionName}/**/nls.metadata.json`], { allowEmpty: true }).pipe(through(function (file: File) { gulp.src([`.build/extensions/${extensionName}/package.nls.json`, `.build/extensions/${extensionName}/**/nls.metadata.json`], { allowEmpty: true }).pipe(through(function (file: File) {
if (file.isBuffer()) { if (file.isBuffer()) {
const buffer: Buffer = file.contents as Buffer; const buffer: Buffer = file.contents as Buffer;
const basename = path.basename(file.path); const basename = path.basename(file.path);
@@ -729,7 +729,7 @@ export function createXlfFilesForExtensions(): ThroughStream {
getXlf().addFile(`extensions/${extensionName}/package`, keys, messages); getXlf().addFile(`extensions/${extensionName}/package`, keys, messages);
} else if (basename === 'nls.metadata.json') { } else if (basename === 'nls.metadata.json') {
const json: BundledExtensionFormat = JSON.parse(buffer.toString('utf8')); const json: BundledExtensionFormat = JSON.parse(buffer.toString('utf8'));
const relPath = path.relative(`./extensions/${extensionName}`, path.dirname(file.path)); const relPath = path.relative(`.build/extensions/${extensionName}`, path.dirname(file.path));
for (let file in json) { for (let file in json) {
const fileContent = json[file]; const fileContent = json[file];
getXlf().addFile(`extensions/${extensionName}/${relPath}/${file}`, fileContent.keys, fileContent.messages); getXlf().addFile(`extensions/${extensionName}/${relPath}/${file}`, fileContent.keys, fileContent.messages);
@@ -1053,8 +1053,8 @@ export function pullCoreAndExtensionsXlfFiles(apiHostname: string, username: str
// extensions // extensions
let extensionsToLocalize = Object.create(null); let extensionsToLocalize = Object.create(null);
glob.sync('./extensions/**/*.nls.json').forEach(extension => extensionsToLocalize[extension.split('/')[2]] = true); glob.sync('.build/extensions/**/*.nls.json').forEach(extension => extensionsToLocalize[extension.split('/')[2]] = true);
glob.sync('./extensions/*/node_modules/vscode-nls').forEach(extension => extensionsToLocalize[extension.split('/')[2]] = true); glob.sync('.build/extensions/*/node_modules/vscode-nls').forEach(extension => extensionsToLocalize[extension.split('/')[2]] = true);
Object.keys(extensionsToLocalize).forEach(extension => { Object.keys(extensionsToLocalize).forEach(extension => {
_coreAndExtensionResources.push({ name: extension, project: extensionsProject }); _coreAndExtensionResources.push({ name: extension, project: extensionsProject });
@@ -1253,7 +1253,7 @@ export function prepareI18nPackFiles(externalExtensions: Map<string>, resultingT
this.queue(translatedMainFile); this.queue(translatedMainFile);
for (let extension in extensionsPacks) { for (let extension in extensionsPacks) {
const translatedExtFile = createI18nFile(`./extensions/${extension}`, extensionsPacks[extension]); const translatedExtFile = createI18nFile(`.build/extensions/${extension}`, extensionsPacks[extension]);
this.queue(translatedExtFile); this.queue(translatedExtFile);
const externalExtensionId = externalExtensions[extension]; const externalExtensionId = externalExtensions[extension];

View File

@@ -5,6 +5,7 @@
'use strict'; 'use strict';
Object.defineProperty(exports, "__esModule", { value: true }); Object.defineProperty(exports, "__esModule", { value: true });
const es = require("event-stream"); const es = require("event-stream");
const fs = require("fs");
const gulp = require("gulp"); const gulp = require("gulp");
const concat = require("gulp-concat"); const concat = require("gulp-concat");
const minifyCSS = require("gulp-cssnano"); const minifyCSS = require("gulp-cssnano");
@@ -17,7 +18,7 @@ const fancyLog = require("fancy-log");
const ansiColors = require("ansi-colors"); const ansiColors = require("ansi-colors");
const path = require("path"); const path = require("path");
const pump = require("pump"); const pump = require("pump");
const uglifyes = require("uglify-es"); const terser = require("terser");
const VinylFile = require("vinyl"); const VinylFile = require("vinyl");
const bundle = require("./bundle"); const bundle = require("./bundle");
const i18n_1 = require("./i18n"); const i18n_1 = require("./i18n");
@@ -134,6 +135,14 @@ function optimizeTask(opts) {
if (err || !result) { if (err || !result) {
return bundlesStream.emit('error', JSON.stringify(err)); return bundlesStream.emit('error', JSON.stringify(err));
} }
if (opts.inlineAmdImages) {
try {
result = inlineAmdImages(src, result);
}
catch (err) {
return bundlesStream.emit('error', JSON.stringify(err));
}
}
toBundleStream(src, bundledFileHeader, result.files).pipe(bundlesStream); toBundleStream(src, bundledFileHeader, result.files).pipe(bundlesStream);
// Remove css inlined resources // Remove css inlined resources
const filteredResources = resources.slice(); const filteredResources = resources.slice();
@@ -169,6 +178,39 @@ function optimizeTask(opts) {
}; };
} }
exports.optimizeTask = optimizeTask; exports.optimizeTask = optimizeTask;
function inlineAmdImages(src, result) {
for (const outputFile of result.files) {
for (const sourceFile of outputFile.sources) {
if (sourceFile.path && /\.js$/.test(sourceFile.path)) {
sourceFile.contents = sourceFile.contents.replace(/\([^.]+\.registerAndGetAmdImageURL\(([^)]+)\)\)/g, (_, m0) => {
let imagePath = m0;
// remove `` or ''
if ((imagePath.charAt(0) === '`' && imagePath.charAt(imagePath.length - 1) === '`')
|| (imagePath.charAt(0) === '\'' && imagePath.charAt(imagePath.length - 1) === '\'')) {
imagePath = imagePath.substr(1, imagePath.length - 2);
}
if (!/\.(png|svg)$/.test(imagePath)) {
console.log(`original: ${_}`);
return _;
}
const repoLocation = path.join(src, imagePath);
const absoluteLocation = path.join(REPO_ROOT_PATH, repoLocation);
if (!fs.existsSync(absoluteLocation)) {
const message = `Invalid amd image url in file ${sourceFile.path}: ${imagePath}`;
console.log(message);
throw new Error(message);
}
const fileContents = fs.readFileSync(absoluteLocation);
const mime = /\.svg$/.test(imagePath) ? 'image/svg+xml' : 'image/png';
// Mark the file as inlined so we don't ship it by itself
result.cssInlinedResources.push(repoLocation);
return `("data:${mime};base64,${fileContents.toString('base64')}")`;
});
}
}
}
return result;
}
/** /**
* Wrap around uglify and allow the preserveComments function * Wrap around uglify and allow the preserveComments function
* to have a file "context" to include our copyright only once per file. * to have a file "context" to include our copyright only once per file.
@@ -199,7 +241,7 @@ function uglifyWithCopyrights() {
return false; return false;
}; };
}; };
const minify = composer(uglifyes); const minify = composer(terser);
const input = es.through(); const input = es.through();
const output = input const output = input
.pipe(flatmap((stream, f) => { .pipe(flatmap((stream, f) => {

View File

@@ -6,6 +6,7 @@
'use strict'; 'use strict';
import * as es from 'event-stream'; import * as es from 'event-stream';
import * as fs from 'fs';
import * as gulp from 'gulp'; import * as gulp from 'gulp';
import * as concat from 'gulp-concat'; import * as concat from 'gulp-concat';
import * as minifyCSS from 'gulp-cssnano'; import * as minifyCSS from 'gulp-cssnano';
@@ -19,7 +20,7 @@ import * as ansiColors from 'ansi-colors';
import * as path from 'path'; import * as path from 'path';
import * as pump from 'pump'; import * as pump from 'pump';
import * as sm from 'source-map'; import * as sm from 'source-map';
import * as uglifyes from 'uglify-es'; import * as terser from 'terser';
import * as VinylFile from 'vinyl'; import * as VinylFile from 'vinyl';
import * as bundle from './bundle'; import * as bundle from './bundle';
import { Language, processNlsFiles } from './i18n'; import { Language, processNlsFiles } from './i18n';
@@ -161,6 +162,10 @@ export interface IOptimizeTaskOpts {
* (emit bundleInfo.json file) * (emit bundleInfo.json file)
*/ */
bundleInfo: boolean; bundleInfo: boolean;
/**
* replace calls to `registerAndGetAmdImageURL` with data uris
*/
inlineAmdImages: boolean;
/** /**
* (out folder name) * (out folder name)
*/ */
@@ -194,6 +199,14 @@ export function optimizeTask(opts: IOptimizeTaskOpts): () => NodeJS.ReadWriteStr
bundle.bundle(entryPoints, loaderConfig, function (err, result) { bundle.bundle(entryPoints, loaderConfig, function (err, result) {
if (err || !result) { return bundlesStream.emit('error', JSON.stringify(err)); } if (err || !result) { return bundlesStream.emit('error', JSON.stringify(err)); }
if (opts.inlineAmdImages) {
try {
result = inlineAmdImages(src, result);
} catch (err) {
return bundlesStream.emit('error', JSON.stringify(err));
}
}
toBundleStream(src, bundledFileHeader, result.files).pipe(bundlesStream); toBundleStream(src, bundledFileHeader, result.files).pipe(bundlesStream);
// Remove css inlined resources // Remove css inlined resources
@@ -238,6 +251,42 @@ export function optimizeTask(opts: IOptimizeTaskOpts): () => NodeJS.ReadWriteStr
}; };
} }
function inlineAmdImages(src: string, result: bundle.IBundleResult): bundle.IBundleResult {
for (const outputFile of result.files) {
for (const sourceFile of outputFile.sources) {
if (sourceFile.path && /\.js$/.test(sourceFile.path)) {
sourceFile.contents = sourceFile.contents.replace(/\([^.]+\.registerAndGetAmdImageURL\(([^)]+)\)\)/g, (_, m0) => {
let imagePath = m0;
// remove `` or ''
if ((imagePath.charAt(0) === '`' && imagePath.charAt(imagePath.length - 1) === '`')
|| (imagePath.charAt(0) === '\'' && imagePath.charAt(imagePath.length - 1) === '\'')) {
imagePath = imagePath.substr(1, imagePath.length - 2);
}
if (!/\.(png|svg)$/.test(imagePath)) {
console.log(`original: ${_}`);
return _;
}
const repoLocation = path.join(src, imagePath);
const absoluteLocation = path.join(REPO_ROOT_PATH, repoLocation);
if (!fs.existsSync(absoluteLocation)) {
const message = `Invalid amd image url in file ${sourceFile.path}: ${imagePath}`;
console.log(message);
throw new Error(message);
}
const fileContents = fs.readFileSync(absoluteLocation);
const mime = /\.svg$/.test(imagePath) ? 'image/svg+xml' : 'image/png';
// Mark the file as inlined so we don't ship it by itself
result.cssInlinedResources.push(repoLocation);
return `("data:${mime};base64,${fileContents.toString('base64')}")`;
});
}
}
}
return result;
}
declare class FileWithCopyright extends VinylFile { declare class FileWithCopyright extends VinylFile {
public __hasOurCopyright: boolean; public __hasOurCopyright: boolean;
} }
@@ -275,7 +324,7 @@ function uglifyWithCopyrights(): NodeJS.ReadWriteStream {
}; };
}; };
const minify = (composer as any)(uglifyes); const minify = (composer as any)(terser);
const input = es.through(); const input = es.through();
const output = input const output = input
.pipe(flatmap((stream, f) => { .pipe(flatmap((stream, f) => {

View File

@@ -11,6 +11,9 @@ const Lint = require("tslint");
*/ */
class Rule extends Lint.Rules.AbstractRule { class Rule extends Lint.Rules.AbstractRule {
apply(sourceFile) { apply(sourceFile) {
if (/\.d.ts$/.test(sourceFile.fileName)) {
return [];
}
return this.applyWithWalker(new NoUnexternalizedStringsRuleWalker(sourceFile, this.getOptions())); return this.applyWithWalker(new NoUnexternalizedStringsRuleWalker(sourceFile, this.getOptions()));
} }
} }

View File

@@ -11,6 +11,9 @@ import * as Lint from 'tslint';
*/ */
export class Rule extends Lint.Rules.AbstractRule { export class Rule extends Lint.Rules.AbstractRule {
public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] { public apply(sourceFile: ts.SourceFile): Lint.RuleFailure[] {
if (/\.d.ts$/.test(sourceFile.fileName)) {
return [];
}
return this.applyWithWalker(new NoUnexternalizedStringsRuleWalker(sourceFile, this.getOptions())); return this.applyWithWalker(new NoUnexternalizedStringsRuleWalker(sourceFile, this.getOptions()));
} }
} }

View File

@@ -7,10 +7,12 @@ declare module "gulp-tsb" {
} }
export interface IncrementalCompiler { export interface IncrementalCompiler {
(token?:ICancellationToken): NodeJS.ReadWriteStream; (token?: ICancellationToken): NodeJS.ReadWriteStream;
// program?: ts.Program; src(opts?: {
cwd?: string;
base?: string;
}): NodeJS.ReadStream;
} }
export function create(projectPath: string, existingOptions: any, verbose?: boolean, onError?: (message: any) => void): IncrementalCompiler;
export function create(configOrName: { [option: string]: string | number | boolean; } | string, verbose?: boolean, json?: boolean, onError?: (message: any) => void): IncrementalCompiler; }
}

View File

@@ -121,7 +121,7 @@ function loadSourcemaps() {
return; return;
} }
if (!f.contents) { if (!f.contents) {
cb(new Error('empty file')); cb(undefined, f);
return; return;
} }
const contents = f.contents.toString('utf8'); const contents = f.contents.toString('utf8');

View File

@@ -165,7 +165,7 @@ export function loadSourcemaps(): NodeJS.ReadWriteStream {
} }
if (!f.contents) { if (!f.contents) {
cb(new Error('empty file')); cb(undefined, f);
return; return;
} }

View File

@@ -5,17 +5,6 @@
const es = require('event-stream'); const es = require('event-stream');
/** Ugly hack for gulp-tsb */
function handleDeletions() {
return es.mapSync(f => {
if (/\.ts$/.test(f.relative) && !f.contents) {
f.contents = Buffer.from('');
f.stat = { mtime: new Date() };
}
return f;
});
}
let watch = undefined; let watch = undefined;
@@ -24,6 +13,5 @@ if (!watch) {
} }
module.exports = function () { module.exports = function () {
return watch.apply(null, arguments) return watch.apply(null, arguments);
.pipe(handleDeletions());
}; };

View File

@@ -148,8 +148,9 @@ function getMassagedTopLevelDeclarationText(sourceFile, declaration, importName,
} }
}); });
} }
result = result.replace(/export default/g, 'export'); result = result.replace(/export default /g, 'export ');
result = result.replace(/export declare/g, 'export'); result = result.replace(/export declare /g, 'export ');
result = result.replace(/declare /g, '');
if (declaration.kind === ts.SyntaxKind.EnumDeclaration) { if (declaration.kind === ts.SyntaxKind.EnumDeclaration) {
result = result.replace(/const enum/, 'enum'); result = result.replace(/const enum/, 'enum');
enums.push(result); enums.push(result);

View File

@@ -178,8 +178,9 @@ function getMassagedTopLevelDeclarationText(sourceFile: ts.SourceFile, declarati
} }
}); });
} }
result = result.replace(/export default/g, 'export'); result = result.replace(/export default /g, 'export ');
result = result.replace(/export declare/g, 'export'); result = result.replace(/export declare /g, 'export ');
result = result.replace(/declare /g, '');
if (declaration.kind === ts.SyntaxKind.EnumDeclaration) { if (declaration.kind === ts.SyntaxKind.EnumDeclaration) {
result = result.replace(/const enum/, 'enum'); result = result.replace(/const enum/, 'enum');

View File

@@ -62,6 +62,7 @@ export interface ICommandHandler {
#includeAll(vs/editor/common/editorCommon;editorOptions.=>): IScrollEvent #includeAll(vs/editor/common/editorCommon;editorOptions.=>): IScrollEvent
#includeAll(vs/editor/common/model/textModelEvents): #includeAll(vs/editor/common/model/textModelEvents):
#includeAll(vs/editor/common/controller/cursorEvents): #includeAll(vs/editor/common/controller/cursorEvents):
#include(vs/platform/accessibility/common/accessibility): AccessibilitySupport
#includeAll(vs/editor/common/config/editorOptions): #includeAll(vs/editor/common/config/editorOptions):
#includeAll(vs/editor/browser/editorBrowser;editorCommon.=>;editorOptions.=>): #includeAll(vs/editor/browser/editorBrowser;editorCommon.=>;editorOptions.=>):
#include(vs/editor/common/config/fontInfo): FontInfo, BareFontInfo #include(vs/editor/common/config/fontInfo): FontInfo, BareFontInfo

View File

@@ -1,7 +1,7 @@
{ {
"name": "monaco-editor-core", "name": "monaco-editor-core",
"private": true, "private": true,
"version": "0.16.0", "version": "0.18.0",
"description": "A browser based code editor", "description": "A browser based code editor",
"author": "Microsoft Corporation", "author": "Microsoft Corporation",
"license": "MIT", "license": "MIT",

View File

@@ -70,6 +70,7 @@ runtime "${runtime}"`;
} }
yarnInstall(`build`); // node modules required for build yarnInstall(`build`); // node modules required for build
yarnInstall('test/automation'); // node modules required for smoketest
yarnInstall('test/smoke'); // node modules required for smoketest yarnInstall('test/smoke'); // node modules required for smoketest
yarnInstallBuildDependencies(); // node modules for watching, specific to host node version, not electron yarnInstallBuildDependencies(); // node modules for watching, specific to host node version, not electron

View File

@@ -24,9 +24,9 @@
"@types/pump": "^1.0.1", "@types/pump": "^1.0.1",
"@types/request": "^2.47.0", "@types/request": "^2.47.0",
"@types/rimraf": "^2.0.2", "@types/rimraf": "^2.0.2",
"@types/terser": "^3.12.0",
"@types/through": "^0.0.29", "@types/through": "^0.0.29",
"@types/through2": "^2.0.34", "@types/through2": "^2.0.34",
"@types/uglify-es": "^3.0.0",
"@types/underscore": "^1.8.9", "@types/underscore": "^1.8.9",
"@types/xml2js": "0.0.33", "@types/xml2js": "0.0.33",
"applicationinsights": "1.0.8", "applicationinsights": "1.0.8",
@@ -36,13 +36,15 @@
"github-releases": "^0.4.1", "github-releases": "^0.4.1",
"gulp-bom": "^1.0.0", "gulp-bom": "^1.0.0",
"gulp-sourcemaps": "^1.11.0", "gulp-sourcemaps": "^1.11.0",
"gulp-uglify": "^3.0.0",
"iconv-lite": "0.4.23", "iconv-lite": "0.4.23",
"mime": "^1.3.4", "mime": "^1.3.4",
"minimist": "^1.2.0", "minimist": "^1.2.0",
"request": "^2.85.0", "request": "^2.85.0",
"terser": "4.3.1",
"tslint": "^5.9.1", "tslint": "^5.9.1",
"service-downloader": "github:anthonydresser/service-downloader#0.1.7", "service-downloader": "github:anthonydresser/service-downloader#0.1.7",
"typescript": "3.5.2", "typescript": "3.6.2",
"vsce": "1.48.0", "vsce": "1.48.0",
"vscode-telemetry-extractor": "^1.5.4", "vscode-telemetry-extractor": "^1.5.4",
"xml2js": "^0.4.17" "xml2js": "^0.4.17"

View File

@@ -217,6 +217,13 @@
"@types/glob" "*" "@types/glob" "*"
"@types/node" "*" "@types/node" "*"
"@types/terser@^3.12.0":
version "3.12.0"
resolved "https://registry.yarnpkg.com/@types/terser/-/terser-3.12.0.tgz#25e020fe9a7a6ae92ce46261f00ced67de6c12ac"
integrity sha512-J0Wy8A7ULEqVJftkWhrXZbH0iBk4tYuTj0gBiiveKaY9deNi6cCsxl0ApJ27ojqwYv51bvEw85lOb8Wt4ng9zA==
dependencies:
terser "*"
"@types/through2@^2.0.34": "@types/through2@^2.0.34":
version "2.0.34" version "2.0.34"
resolved "https://registry.yarnpkg.com/@types/through2/-/through2-2.0.34.tgz#9c2a259a238dace2a05a2f8e94b786961bc27ac4" resolved "https://registry.yarnpkg.com/@types/through2/-/through2-2.0.34.tgz#9c2a259a238dace2a05a2f8e94b786961bc27ac4"
@@ -236,20 +243,6 @@
resolved "https://registry.yarnpkg.com/@types/tough-cookie/-/tough-cookie-2.3.2.tgz#e0d481d8bb282ad8a8c9e100ceb72c995fb5e709" resolved "https://registry.yarnpkg.com/@types/tough-cookie/-/tough-cookie-2.3.2.tgz#e0d481d8bb282ad8a8c9e100ceb72c995fb5e709"
integrity sha512-vOVmaruQG5EatOU/jM6yU2uCp3Lz6mK1P5Ztu4iJjfM4SVHU9XYktPUQtKlIXuahqXHdEyUarMrBEwg5Cwu+bA== integrity sha512-vOVmaruQG5EatOU/jM6yU2uCp3Lz6mK1P5Ztu4iJjfM4SVHU9XYktPUQtKlIXuahqXHdEyUarMrBEwg5Cwu+bA==
"@types/uglify-es@^3.0.0":
version "3.0.0"
resolved "https://registry.yarnpkg.com/@types/uglify-es/-/uglify-es-3.0.0.tgz#2c5e70b43c0e86643ac1c223f61df15fa0b87bc2"
integrity sha512-Oc/c7pGIQL0MVhC6g+VftWiDQethKsT4c3fQKYm6nOprkvkx9s1MLrnJprDTKlZL3ZJulMpCF9Qn7s6u3uCNxQ==
dependencies:
"@types/uglify-js" "*"
"@types/uglify-js@*":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-3.0.3.tgz#801a5ca1dc642861f47c46d14b700ed2d610840b"
integrity sha512-MAT0BW2ruO0LhQKjvlipLGCF/Yx0y/cj+tT67tK3QIQDrM2+9R78HgJ54VlrE8AbfjYJJBCQCEPM5ZblPVTuww==
dependencies:
source-map "^0.6.1"
"@types/uglify-js@^2": "@types/uglify-js@^2":
version "2.6.32" version "2.6.32"
resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-2.6.32.tgz#1b60906946fcf6ee4ceafa812d2b86f1358da904" resolved "https://registry.yarnpkg.com/@types/uglify-js/-/uglify-js-2.6.32.tgz#1b60906946fcf6ee4ceafa812d2b86f1358da904"
@@ -433,6 +426,11 @@ array-differ@^3.0.0:
resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-3.0.0.tgz#3cbb3d0f316810eafcc47624734237d6aee4ae6b" resolved "https://registry.yarnpkg.com/array-differ/-/array-differ-3.0.0.tgz#3cbb3d0f316810eafcc47624734237d6aee4ae6b"
integrity sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg== integrity sha512-THtfYS6KtME/yIAhKjZ2ul7XI96lQGHRputJQHO80LAWQnuGP4iCIN8vdMRboGbIEYBwU33q8Tch1os2+X0kMg==
array-each@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/array-each/-/array-each-1.0.1.tgz#a794af0c05ab1752846ee753a1f211a05ba0c44f"
integrity sha1-p5SvDAWrF1KEbudTofIRoFugxE8=
array-union@^1.0.1: array-union@^1.0.1:
version "1.0.2" version "1.0.2"
resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39" resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39"
@@ -686,6 +684,11 @@ buffer-fill@^1.0.0:
resolved "https://registry.yarnpkg.com/buffer-fill/-/buffer-fill-1.0.0.tgz#f8f78b76789888ef39f205cd637f68e702122b2c" resolved "https://registry.yarnpkg.com/buffer-fill/-/buffer-fill-1.0.0.tgz#f8f78b76789888ef39f205cd637f68e702122b2c"
integrity sha1-+PeLdniYiO858gXNY39o5wISKyw= integrity sha1-+PeLdniYiO858gXNY39o5wISKyw=
buffer-from@^1.0.0:
version "1.1.1"
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef"
integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==
buffer@^5.2.1: buffer@^5.2.1:
version "5.2.1" version "5.2.1"
resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.2.1.tgz#dd57fa0f109ac59c602479044dca7b8b3d0b71d6" resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.2.1.tgz#dd57fa0f109ac59c602479044dca7b8b3d0b71d6"
@@ -869,6 +872,11 @@ commander@^2.12.1, commander@^2.8.1:
resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a" resolved "https://registry.yarnpkg.com/commander/-/commander-2.19.0.tgz#f6198aa84e5b83c46054b94ddedbfed5ee9ff12a"
integrity sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg== integrity sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==
commander@^2.20.0, commander@~2.20.0:
version "2.20.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.0.tgz#d58bb2b5c1ee8f87b0d340027e9e94e222c5a422"
integrity sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==
commander@~2.8.1: commander@~2.8.1:
version "2.8.1" version "2.8.1"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.8.1.tgz#06be367febfda0c330aa1e2a072d3dc9762425d4" resolved "https://registry.yarnpkg.com/commander/-/commander-2.8.1.tgz#06be367febfda0c330aa1e2a072d3dc9762425d4"
@@ -1619,6 +1627,22 @@ gulp-sourcemaps@^1.11.0:
through2 "2.X" through2 "2.X"
vinyl "1.X" vinyl "1.X"
gulp-uglify@^3.0.0:
version "3.0.2"
resolved "https://registry.yarnpkg.com/gulp-uglify/-/gulp-uglify-3.0.2.tgz#5f5b2e8337f879ca9dec971feb1b82a5a87850b0"
integrity sha512-gk1dhB74AkV2kzqPMQBLA3jPoIAPd/nlNzP2XMDSG8XZrqnlCiDGAqC+rZOumzFvB5zOphlFh6yr3lgcAb/OOg==
dependencies:
array-each "^1.0.1"
extend-shallow "^3.0.2"
gulplog "^1.0.0"
has-gulplog "^0.1.0"
isobject "^3.0.1"
make-error-cause "^1.1.1"
safe-buffer "^5.1.2"
through2 "^2.0.0"
uglify-js "^3.0.5"
vinyl-sourcemaps-apply "^0.2.0"
gulp-util@^3.0.0: gulp-util@^3.0.0:
version "3.0.8" version "3.0.8"
resolved "https://registry.yarnpkg.com/gulp-util/-/gulp-util-3.0.8.tgz#0054e1e744502e27c04c187c3ecc505dd54bbb4f" resolved "https://registry.yarnpkg.com/gulp-util/-/gulp-util-3.0.8.tgz#0054e1e744502e27c04c187c3ecc505dd54bbb4f"
@@ -2320,6 +2344,18 @@ make-dir@^1.0.0:
dependencies: dependencies:
pify "^3.0.0" pify "^3.0.0"
make-error-cause@^1.1.1:
version "1.2.2"
resolved "https://registry.yarnpkg.com/make-error-cause/-/make-error-cause-1.2.2.tgz#df0388fcd0b37816dff0a5fb8108939777dcbc9d"
integrity sha1-3wOI/NCzeBbf8KX7gQiTl3fcvJ0=
dependencies:
make-error "^1.2.0"
make-error@^1.2.0:
version "1.3.5"
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.5.tgz#efe4e81f6db28cadd605c70f29c831b58ef776c8"
integrity sha512-c3sIjNUow0+8swNwVpqoH4YCShKNFkMaw6oH1mNS2haDZQqkeZFlHS3dhoeEbKKmJB4vXpJucU6oH75aDYeE9g==
map-cache@^0.2.2: map-cache@^0.2.2:
version "0.2.2" version "0.2.2"
resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf"
@@ -3017,7 +3053,12 @@ safe-buffer@^5.0.1, safe-buffer@^5.1.1:
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853"
integrity sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg== integrity sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==
safe-buffer@^5.1.2, safe-buffer@~5.1.0, safe-buffer@~5.1.1: safe-buffer@^5.1.2:
version "5.2.0"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.0.tgz#b74daec49b1148f88c64b68d49b1e815c1f2f519"
integrity sha512-fZEwUGbVl7kouZs1jCdMLdt95hdIv0ZeHg6L7qPeciMZhZ+/gdesW4wgTARkrFWEpspjEATAzUGPG8N2jJiwbg==
safe-buffer@~5.1.0, safe-buffer@~5.1.1:
version "5.1.2" version "5.1.2"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d"
integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==
@@ -3163,17 +3204,25 @@ source-map-resolve@^0.5.0, source-map-resolve@^0.5.2:
source-map-url "^0.4.0" source-map-url "^0.4.0"
urix "^0.1.0" urix "^0.1.0"
source-map-support@~0.5.12:
version "0.5.13"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.13.tgz#31b24a9c2e73c2de85066c0feb7d44767ed52932"
integrity sha512-SHSKFHadjVA5oR4PPqhtAVdcBWwRYVd6g6cAXnIbRiIwc2EhPrTuKUBdSLvlEKyIP3GCf89fltvcZiP9MMFA1w==
dependencies:
buffer-from "^1.0.0"
source-map "^0.6.0"
source-map-url@^0.4.0: source-map-url@^0.4.0:
version "0.4.0" version "0.4.0"
resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3" resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3"
integrity sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM= integrity sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=
source-map@^0.5.6: source-map@^0.5.1, source-map@^0.5.6:
version "0.5.7" version "0.5.7"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc"
integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=
source-map@^0.6.1, source-map@~0.6.0: source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.0, source-map@~0.6.1:
version "0.6.1" version "0.6.1"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
@@ -3323,6 +3372,24 @@ tar@^4:
safe-buffer "^5.1.2" safe-buffer "^5.1.2"
yallist "^3.0.2" yallist "^3.0.2"
terser@*:
version "4.2.1"
resolved "https://registry.yarnpkg.com/terser/-/terser-4.2.1.tgz#1052cfe17576c66e7bc70fcc7119f22b155bdac1"
integrity sha512-cGbc5utAcX4a9+2GGVX4DsenG6v0x3glnDi5hx8816X1McEAwPlPgRtXPJzSBsbpILxZ8MQMT0KvArLuE0HP5A==
dependencies:
commander "^2.20.0"
source-map "~0.6.1"
source-map-support "~0.5.12"
terser@4.3.1:
version "4.3.1"
resolved "https://registry.yarnpkg.com/terser/-/terser-4.3.1.tgz#09820bcb3398299c4b48d9a86aefc65127d0ed65"
integrity sha512-pnzH6dnFEsR2aa2SJaKb1uSCl3QmIsJ8dEkj0Fky+2AwMMcC9doMqLOQIH6wVTEKaVfKVvLSk5qxPBEZT9mywg==
dependencies:
commander "^2.20.0"
source-map "~0.6.1"
source-map-support "~0.5.12"
through2@2.X, through2@^2.0.0, through2@^2.0.3: through2@2.X, through2@^2.0.0, through2@^2.0.3:
version "2.0.3" version "2.0.3"
resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be" resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be"
@@ -3475,10 +3542,10 @@ typed-rest-client@^0.9.0:
tunnel "0.0.4" tunnel "0.0.4"
underscore "1.8.3" underscore "1.8.3"
typescript@3.5.2: typescript@3.6.2:
version "3.5.2" version "3.6.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.2.tgz#a09e1dc69bc9551cadf17dba10ee42cf55e5d56c" resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.6.2.tgz#105b0f1934119dde543ac8eb71af3a91009efe54"
integrity sha512-7KxJovlYhTX5RaRbUdkAXN1KUZ8PwWlTzQdHV6xNqvuFOs7+WBo10TQUqT19Q/Jz2hk5v9TQDIhyLhhJY4p5AA== integrity sha512-lmQ4L+J6mnu3xweP8+rOrUwzmN+MRAj7TgtJtDaXE5PMyX2kCrklhg3rvOsOIfNeAWMQWO2F1GPc1kMD2vLAfw==
typescript@^3.0.1: typescript@^3.0.1:
version "3.5.3" version "3.5.3"
@@ -3495,6 +3562,14 @@ uc.micro@^1.0.1, uc.micro@^1.0.5:
resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.5.tgz#0c65f15f815aa08b560a61ce8b4db7ffc3f45376" resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.5.tgz#0c65f15f815aa08b560a61ce8b4db7ffc3f45376"
integrity sha512-JoLI4g5zv5qNyT09f4YAvEZIIV1oOjqnewYg5D38dkQljIzpPT296dbIGvKro3digYI1bkb7W6EP1y4uDlmzLg== integrity sha512-JoLI4g5zv5qNyT09f4YAvEZIIV1oOjqnewYg5D38dkQljIzpPT296dbIGvKro3digYI1bkb7W6EP1y4uDlmzLg==
uglify-js@^3.0.5:
version "3.6.0"
resolved "https://registry.yarnpkg.com/uglify-js/-/uglify-js-3.6.0.tgz#704681345c53a8b2079fb6cec294b05ead242ff5"
integrity sha512-W+jrUHJr3DXKhrsS7NUVxn3zqMOFn0hL/Ei6v0anCIMoKC93TjcflTagwIHLW7SfMFfiQuktQyFVCFHGUE0+yg==
dependencies:
commander "~2.20.0"
source-map "~0.6.1"
unbzip2-stream@^1.0.9: unbzip2-stream@^1.0.9:
version "1.3.3" version "1.3.3"
resolved "https://registry.yarnpkg.com/unbzip2-stream/-/unbzip2-stream-1.3.3.tgz#d156d205e670d8d8c393e1c02ebd506422873f6a" resolved "https://registry.yarnpkg.com/unbzip2-stream/-/unbzip2-stream-1.3.3.tgz#d156d205e670d8d8c393e1c02ebd506422873f6a"
@@ -3590,6 +3665,13 @@ verror@1.10.0:
core-util-is "1.0.2" core-util-is "1.0.2"
extsprintf "^1.2.0" extsprintf "^1.2.0"
vinyl-sourcemaps-apply@^0.2.0:
version "0.2.1"
resolved "https://registry.yarnpkg.com/vinyl-sourcemaps-apply/-/vinyl-sourcemaps-apply-0.2.1.tgz#ab6549d61d172c2b1b87be5c508d239c8ef87705"
integrity sha1-q2VJ1h0XLCsbh75cUI0jnI74dwU=
dependencies:
source-map "^0.5.1"
vinyl@1.X: vinyl@1.X:
version "1.2.0" version "1.2.0"
resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-1.2.0.tgz#5c88036cf565e5df05558bfc911f8656df218884" resolved "https://registry.yarnpkg.com/vinyl/-/vinyl-1.2.0.tgz#5c88036cf565e5df05558bfc911f8656df218884"
@@ -3632,9 +3714,9 @@ vsce@1.48.0:
yazl "^2.2.2" yazl "^2.2.2"
vscode-ripgrep@^1.5.6: vscode-ripgrep@^1.5.6:
version "1.5.6" version "1.5.7"
resolved "https://registry.yarnpkg.com/vscode-ripgrep/-/vscode-ripgrep-1.5.6.tgz#93bf5c99ca5f8248950a305e224f6ca153c30af4" resolved "https://registry.yarnpkg.com/vscode-ripgrep/-/vscode-ripgrep-1.5.7.tgz#acb6b548af488a4bca5d0f1bb5faf761343289ce"
integrity sha512-WRIM9XpUj6dsfdAmuI3ANbmT1ysPUVsYy/2uCLDHJa9kbiB4T7uGvFnnc0Rgx2qQnyRAwL7PeWaFgUljPPxf2g== integrity sha512-/Vsz/+k8kTvui0q3O74pif9FK0nKopgFTiGNVvxicZANxtSA8J8gUE9GQ/4dpi7D/2yI/YVORszwVskFbz46hQ==
vscode-telemetry-extractor@^1.5.4: vscode-telemetry-extractor@^1.5.4:
version "1.5.4" version "1.5.4"

View File

@@ -48,6 +48,7 @@
}, },
{ {
// Reason: The npm module does not contain a repository field. // Reason: The npm module does not contain a repository field.
// waiting for https://github.com/xtermjs/xterm.js/issues/2395
"name": "xterm-addon-search", "name": "xterm-addon-search",
"fullLicenseText": [ "fullLicenseText": [
"Copyright (c) 2017, The xterm.js authors (https://github.com/xtermjs/xterm.js)", "Copyright (c) 2017, The xterm.js authors (https://github.com/xtermjs/xterm.js)",
@@ -73,6 +74,7 @@
}, },
{ {
// Reason: The npm module does not contain a repository field. // Reason: The npm module does not contain a repository field.
// waiting for https://github.com/xtermjs/xterm.js/issues/2395
"name": "xterm-addon-web-links", "name": "xterm-addon-web-links",
"fullLicenseText": [ "fullLicenseText": [
"Copyright (c) 2017, The xterm.js authors (https://github.com/xtermjs/xterm.js)", "Copyright (c) 2017, The xterm.js authors (https://github.com/xtermjs/xterm.js)",

View File

@@ -60,12 +60,12 @@
"git": { "git": {
"name": "electron", "name": "electron",
"repositoryUrl": "https://github.com/electron/electron", "repositoryUrl": "https://github.com/electron/electron",
"commitHash": "3d4d6454007f14fa9a5f0e1fa49206fb91b676cc" "commitHash": "4e4c7527c63fcf27dffaeb58bde996b8d859c0ed"
} }
}, },
"isOnlyProductionDependency": true, "isOnlyProductionDependency": true,
"license": "MIT", "license": "MIT",
"version": "4.2.9" "version": "4.2.10"
}, },
{ {
"component": { "component": {

View File

@@ -10,8 +10,10 @@ import * as vscode from 'vscode';
import { TelemetryReporter, TelemetryViews } from './telemetry'; import { TelemetryReporter, TelemetryViews } from './telemetry';
import { doubleEscapeSingleQuotes, backEscapeDoubleQuotes, getTelemetryErrorType } from './utils'; import { doubleEscapeSingleQuotes, backEscapeDoubleQuotes, getTelemetryErrorType } from './utils';
import { ChildProcess, exec } from 'child_process'; import { ChildProcess, exec } from 'child_process';
import { promisify } from 'util';
import { readFile } from 'fs';
const localize = nls.loadMessageBundle(); const localize = nls.loadMessageBundle();
const ssmsMinVer = JSON.parse(JSON.stringify(require('./config.json'))).version;
let exePath: string; let exePath: string;
const runningProcesses: Map<number, ChildProcess> = new Map<number, ChildProcess>(); const runningProcesses: Map<number, ChildProcess> = new Map<number, ChildProcess>();
@@ -66,6 +68,8 @@ export interface LaunchSsmsDialogParams {
export async function activate(context: vscode.ExtensionContext): Promise<void> { export async function activate(context: vscode.ExtensionContext): Promise<void> {
// This is for Windows-specific support so do nothing on other platforms // This is for Windows-specific support so do nothing on other platforms
if (process.platform === 'win32') { if (process.platform === 'win32') {
const rawConfig = await promisify(readFile)(path.join(context.extensionPath, 'config.json'));
const ssmsMinVer = JSON.parse(rawConfig.toString()).version;
exePath = path.join(context.extensionPath, 'ssmsmin', 'Windows', ssmsMinVer, 'ssmsmin.exe'); exePath = path.join(context.extensionPath, 'ssmsmin', 'Windows', ssmsMinVer, 'ssmsmin.exe');
registerCommands(context); registerCommands(context);
} }
@@ -259,4 +263,4 @@ export async function buildUrn(node: azdata.objectexplorer.ObjectExplorerNode):
} }
return ['Server'].concat(urnNodes).join('/'); return ['Server'].concat(urnNodes).join('/');
} }

View File

@@ -84,7 +84,7 @@
"mocha-junit-reporter": "^1.17.0", "mocha-junit-reporter": "^1.17.0",
"mocha-multi-reporters": "^1.1.7", "mocha-multi-reporters": "^1.1.7",
"@types/mocha": "^5.2.5", "@types/mocha": "^5.2.5",
"@types/node": "^8.10.25", "@types/node": "^10.14.8",
"mocha": "^5.2.0", "mocha": "^5.2.0",
"should": "^13.2.1", "should": "^13.2.1",
"typemoq": "^2.1.0", "typemoq": "^2.1.0",

View File

@@ -259,9 +259,9 @@ export class JobStepDialog extends AgentDialog<JobStepData> {
title: this.CommandLabelString, title: this.CommandLabelString,
actions: [this.openButton, this.parseButton] actions: [this.openButton, this.parseButton]
}], { }], {
horizontal: false, horizontal: false,
componentWidth: 420 componentWidth: 420
}).component(); }).component();
this.typeDropdown.onValueChanged((type) => { this.typeDropdown.onValueChanged((type) => {
switch (type.selected) { switch (type.selected) {
case (JobStepDialog.TSQLScript): case (JobStepDialog.TSQLScript):
@@ -375,8 +375,8 @@ export class JobStepDialog extends AgentDialog<JobStepData> {
component: this.userInputBox, component: this.userInputBox,
title: this.RunAsUserLabel title: this.RunAsUserLabel
}], { }], {
componentWidth: 400 componentWidth: 400
}).component(); }).component();
let formWrapper = view.modelBuilder.loadingComponent().withItem(formModel).component(); let formWrapper = view.modelBuilder.loadingComponent().withItem(formModel).component();
formWrapper.loading = false; formWrapper.loading = false;
@@ -419,9 +419,9 @@ export class JobStepDialog extends AgentDialog<JobStepData> {
component: this.retryAttemptsBox, component: this.retryAttemptsBox,
title: this.RetryAttemptsLabel title: this.RetryAttemptsLabel
}], { }], {
horizontal: false, horizontal: false,
componentWidth: '100%' componentWidth: '100%'
}) })
.component(); .component();
let retryIntervalContainer = view.modelBuilder.formContainer() let retryIntervalContainer = view.modelBuilder.formContainer()
@@ -430,8 +430,8 @@ export class JobStepDialog extends AgentDialog<JobStepData> {
component: this.retryIntervalBox, component: this.retryIntervalBox,
title: this.RetryIntervalLabel title: this.RetryIntervalLabel
}], { }], {
horizontal: false horizontal: false
}) })
.component(); .component();
let retryFlexContainer = view.modelBuilder.flexContainer() let retryFlexContainer = view.modelBuilder.flexContainer()
@@ -574,4 +574,4 @@ export class JobStepDialog extends AgentDialog<JobStepData> {
return validationResult.valid; return validationResult.valid;
}); });
} }
} }

View File

@@ -7,10 +7,10 @@
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-5.2.6.tgz#b8622d50557dd155e9f2f634b7d68fd38de5e94b" resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-5.2.6.tgz#b8622d50557dd155e9f2f634b7d68fd38de5e94b"
integrity sha512-1axi39YdtBI7z957vdqXI4Ac25e7YihYQtJa+Clnxg1zTJEaIRbndt71O3sP4GAMgiAm0pY26/b9BrY4MR/PMw== integrity sha512-1axi39YdtBI7z957vdqXI4Ac25e7YihYQtJa+Clnxg1zTJEaIRbndt71O3sP4GAMgiAm0pY26/b9BrY4MR/PMw==
"@types/node@^8.10.25": "@types/node@^10.14.8":
version "8.10.45" version "10.14.17"
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.10.45.tgz#4c49ba34106bc7dced77ff6bae8eb6543cde8351" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.17.tgz#b96d4dd3e427382482848948041d3754d40fd5ce"
integrity sha512-tGVTbA+i3qfXsLbq9rEq/hezaHY55QxQLeXQL2ejNgFAxxrgu8eMmYIOsRcl7hN1uTLVsKOOYacV/rcJM3sfgQ== integrity sha512-p/sGgiPaathCfOtqu2fx5Mu1bcjuP8ALFg4xpGgNkcin7LwRyzUKniEHBKdcE1RPsenq5JVPIpMTJSygLboygQ==
ajv@^6.5.5: ajv@^6.5.5:
version "6.10.0" version "6.10.0"

View File

@@ -627,7 +627,7 @@
}, },
"devDependencies": { "devDependencies": {
"@types/mocha": "^5.2.5", "@types/mocha": "^5.2.5",
"@types/node": "^8.0.24", "@types/node": "^10.14.8",
"mocha": "^5.2.0", "mocha": "^5.2.0",
"should": "^13.2.1", "should": "^13.2.1",
"vscode": "^1.1.26", "vscode": "^1.1.26",

View File

@@ -7,10 +7,10 @@
resolved "https://registry.npmjs.org/@types/mocha/-/mocha-5.2.5.tgz#8a4accfc403c124a0bafe8a9fc61a05ec1032073" resolved "https://registry.npmjs.org/@types/mocha/-/mocha-5.2.5.tgz#8a4accfc403c124a0bafe8a9fc61a05ec1032073"
integrity sha512-lAVp+Kj54ui/vLUFxsJTMtWvZraZxum3w3Nwkble2dNuV5VnPA+Mi2oGX9XYJAaIvZi3tn3cbjS/qcJXRb6Bww== integrity sha512-lAVp+Kj54ui/vLUFxsJTMtWvZraZxum3w3Nwkble2dNuV5VnPA+Mi2oGX9XYJAaIvZi3tn3cbjS/qcJXRb6Bww==
"@types/node@^8.0.24": "@types/node@^10.14.8":
version "8.10.36" version "10.14.17"
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.10.36.tgz#eac05d576fbcd0b4ea3c912dc58c20475c08d9e4" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.17.tgz#b96d4dd3e427382482848948041d3754d40fd5ce"
integrity sha512-SL6KhfM7PTqiFmbCW3eVNwVBZ+88Mrzbuvn9olPsfv43mbiWaFY+nRcz/TGGku0/lc2FepdMbImdMY1JrQ+zbw== integrity sha512-p/sGgiPaathCfOtqu2fx5Mu1bcjuP8ALFg4xpGgNkcin7LwRyzUKniEHBKdcE1RPsenq5JVPIpMTJSygLboygQ==
ajv@^5.3.0: ajv@^5.3.0:
version "5.5.2" version "5.5.2"

View File

@@ -49,9 +49,9 @@ export class DeployConfigPage extends DacFxConfigPage {
radioButtons, radioButtons,
this.databaseDropdownComponent this.databaseDropdownComponent
], { ], {
horizontal: true, horizontal: true,
componentWidth: 400 componentWidth: 400
}); });
this.form = this.formBuilder.component(); this.form = this.formBuilder.component();
await this.view.initializeModel(this.form); await this.view.initializeModel(this.form);

View File

@@ -69,8 +69,8 @@ export class DeployPlanPage extends DacFxConfigPage {
}, },
this.dataLossComponentGroup this.dataLossComponentGroup
], { ], {
horizontal: true, horizontal: true,
}); });
this.form = this.formBuilder.component(); this.form = this.formBuilder.component();
await this.view.initializeModel(this.form); await this.view.initializeModel(this.form);

View File

@@ -39,9 +39,9 @@ export class ExportConfigPage extends DacFxConfigPage {
databaseComponent, databaseComponent,
fileBrowserComponent, fileBrowserComponent,
], { ], {
horizontal: true, horizontal: true,
componentWidth: 400 componentWidth: 400
}).component(); }).component();
await this.view.initializeModel(this.form); await this.view.initializeModel(this.form);
return true; return true;
} }

View File

@@ -42,9 +42,9 @@ export class ExtractConfigPage extends DacFxConfigPage {
versionComponent, versionComponent,
fileBrowserComponent, fileBrowserComponent,
], { ], {
horizontal: true, horizontal: true,
componentWidth: 400 componentWidth: 400
}).component(); }).component();
await this.view.initializeModel(this.form); await this.view.initializeModel(this.form);
return true; return true;
} }

View File

@@ -41,9 +41,9 @@ export class ImportConfigPage extends DacFxConfigPage {
serverComponent, serverComponent,
databaseComponent, databaseComponent,
], { ], {
horizontal: true, horizontal: true,
componentWidth: 400 componentWidth: 400
}).component(); }).component();
await this.view.initializeModel(this.form); await this.view.initializeModel(this.form);
return true; return true;
} }

View File

@@ -51,8 +51,8 @@ export class SelectOperationPage extends BasePage {
importComponent, importComponent,
exportComponent exportComponent
], { ], {
horizontal: true horizontal: true
}).component(); }).component();
await this.view.initializeModel(this.form); await this.view.initializeModel(this.form);
this.instance.setDoneButton(Operation.deploy); this.instance.setDoneButton(Operation.deploy);

View File

@@ -73,7 +73,7 @@
"config.autofetch": "When enabled, commits will automatically be fetched from the default remote of the current Git repository.", "config.autofetch": "When enabled, commits will automatically be fetched from the default remote of the current Git repository.",
"config.autofetchPeriod": "Duration in seconds between each automatic git fetch, when `git.autofetch` is enabled.", "config.autofetchPeriod": "Duration in seconds between each automatic git fetch, when `git.autofetch` is enabled.",
"config.confirmSync": "Confirm before synchronizing git repositories.", "config.confirmSync": "Confirm before synchronizing git repositories.",
"config.countBadge": "Controls the git badge counter.", "config.countBadge": "Controls the Git count badge.",
"config.countBadge.all": "Count all changes.", "config.countBadge.all": "Count all changes.",
"config.countBadge.tracked": "Count only tracked changes.", "config.countBadge.tracked": "Count only tracked changes.",
"config.countBadge.off": "Turn off counter.", "config.countBadge.off": "Turn off counter.",

View File

@@ -1260,7 +1260,7 @@ export class CommandCenter {
if (documents.length > 0) { if (documents.length > 0) {
const message = documents.length === 1 const message = documents.length === 1
? localize('unsaved files single', "The following file is unsaved and will not be included in the commit if you proceed: {0}.\n\nWould you like to save it before committing?", path.basename(documents[0].uri.fsPath)) ? localize('unsaved files single', "The following file has unsaved changes which won't be included in the commit if you proceed: {0}.\n\nWould you like to save it before committing?", path.basename(documents[0].uri.fsPath))
: localize('unsaved files', "There are {0} unsaved files.\n\nWould you like to save them before committing?", documents.length); : localize('unsaved files', "There are {0} unsaved files.\n\nWould you like to save them before committing?", documents.length);
const saveAndCommit = localize('save and commit', "Save All & Commit"); const saveAndCommit = localize('save and commit', "Save All & Commit");
const commit = localize('commit', "Commit Anyway"); const commit = localize('commit', "Commit Anyway");

View File

@@ -3,13 +3,13 @@
* Licensed under the Source EULA. See License.txt in the project root for license information. * Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { window, workspace, Uri, Disposable, Event, EventEmitter, DecorationData, DecorationProvider, ThemeColor } from 'vscode'; import { window, workspace, Uri, Disposable, Event, EventEmitter, Decoration, DecorationProvider, ThemeColor } from 'vscode';
import * as path from 'path'; import * as path from 'path';
import { Repository, GitResourceGroup } from './repository'; import { Repository, GitResourceGroup } from './repository';
import { Model } from './model'; import { Model } from './model';
import { debounce } from './decorators'; import { debounce } from './decorators';
import { filterEvent, dispose, anyEvent, fireEvent } from './util'; import { filterEvent, dispose, anyEvent, fireEvent } from './util';
import { GitErrorCodes, Status } from './api/git'; import { GitErrorCodes } from './api/git';
type Callback = { resolve: (status: boolean) => void, reject: (err: any) => void }; type Callback = { resolve: (status: boolean) => void, reject: (err: any) => void };
@@ -29,7 +29,7 @@ class GitIgnoreDecorationProvider implements DecorationProvider {
this.disposables.push(window.registerDecorationProvider(this)); this.disposables.push(window.registerDecorationProvider(this));
} }
provideDecoration(uri: Uri): Promise<DecorationData | undefined> { provideDecoration(uri: Uri): Promise<Decoration | undefined> {
const repository = this.model.getRepository(uri); const repository = this.model.getRepository(uri);
if (!repository) { if (!repository) {
@@ -48,7 +48,7 @@ class GitIgnoreDecorationProvider implements DecorationProvider {
this.checkIgnoreSoon(); this.checkIgnoreSoon();
}).then(ignored => { }).then(ignored => {
if (ignored) { if (ignored) {
return <DecorationData>{ return <Decoration>{
priority: 3, priority: 3,
color: new ThemeColor('gitDecoration.ignoredResourceForeground') color: new ThemeColor('gitDecoration.ignoredResourceForeground')
}; };
@@ -89,7 +89,7 @@ class GitIgnoreDecorationProvider implements DecorationProvider {
class GitDecorationProvider implements DecorationProvider { class GitDecorationProvider implements DecorationProvider {
private static SubmoduleDecorationData: DecorationData = { private static SubmoduleDecorationData: Decoration = {
title: 'Submodule', title: 'Submodule',
letter: 'S', letter: 'S',
color: new ThemeColor('gitDecoration.submoduleResourceForeground') color: new ThemeColor('gitDecoration.submoduleResourceForeground')
@@ -99,7 +99,7 @@ class GitDecorationProvider implements DecorationProvider {
readonly onDidChangeDecorations: Event<Uri[]> = this._onDidChangeDecorations.event; readonly onDidChangeDecorations: Event<Uri[]> = this._onDidChangeDecorations.event;
private disposables: Disposable[] = []; private disposables: Disposable[] = [];
private decorations = new Map<string, DecorationData>(); private decorations = new Map<string, Decoration>();
constructor(private repository: Repository) { constructor(private repository: Repository) {
this.disposables.push( this.disposables.push(
@@ -109,7 +109,7 @@ class GitDecorationProvider implements DecorationProvider {
} }
private onDidRunGitStatus(): void { private onDidRunGitStatus(): void {
let newDecorations = new Map<string, DecorationData>(); let newDecorations = new Map<string, Decoration>();
this.collectSubmoduleDecorationData(newDecorations); this.collectSubmoduleDecorationData(newDecorations);
this.collectDecorationData(this.repository.indexGroup, newDecorations); this.collectDecorationData(this.repository.indexGroup, newDecorations);
@@ -121,25 +121,22 @@ class GitDecorationProvider implements DecorationProvider {
this._onDidChangeDecorations.fire([...uris.values()].map(value => Uri.parse(value, true))); this._onDidChangeDecorations.fire([...uris.values()].map(value => Uri.parse(value, true)));
} }
private collectDecorationData(group: GitResourceGroup, bucket: Map<string, DecorationData>): void { private collectDecorationData(group: GitResourceGroup, bucket: Map<string, Decoration>): void {
group.resourceStates.forEach(r => { group.resourceStates.forEach(r => {
if (r.resourceDecoration if (r.resourceDecoration) {
&& r.type !== Status.DELETED
&& r.type !== Status.INDEX_DELETED
) {
// not deleted and has a decoration // not deleted and has a decoration
bucket.set(r.original.toString(), r.resourceDecoration); bucket.set(r.original.toString(), r.resourceDecoration);
} }
}); });
} }
private collectSubmoduleDecorationData(bucket: Map<string, DecorationData>): void { private collectSubmoduleDecorationData(bucket: Map<string, Decoration>): void {
for (const submodule of this.repository.submodules) { for (const submodule of this.repository.submodules) {
bucket.set(Uri.file(path.join(this.repository.root, submodule.path)).toString(), GitDecorationProvider.SubmoduleDecorationData); bucket.set(Uri.file(path.join(this.repository.root, submodule.path)).toString(), GitDecorationProvider.SubmoduleDecorationData);
} }
} }
provideDecoration(uri: Uri): DecorationData | undefined { provideDecoration(uri: Uri): Decoration | undefined {
return this.decorations.get(uri.toString()); return this.decorations.get(uri.toString());
} }

View File

@@ -1628,7 +1628,7 @@ export class Repository {
const args = ['for-each-ref', '--format', '%(refname) %(objectname)']; const args = ['for-each-ref', '--format', '%(refname) %(objectname)'];
if (opts && opts.sort && opts.sort !== 'alphabetically') { if (opts && opts.sort && opts.sort !== 'alphabetically') {
args.push('--sort', opts.sort); args.push('--sort', `-${opts.sort}`);
} }
const result = await this.run(args); const result = await this.run(args);
@@ -1766,7 +1766,7 @@ export class Repository {
} }
const raw = await readfile(templatePath, 'utf8'); const raw = await readfile(templatePath, 'utf8');
return raw.replace(/\n?#.*/g, ''); return raw.replace(/^\s*#.*$\n?/gm, '');
} catch (err) { } catch (err) {
return ''; return '';

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information. * Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { commands, Uri, Command, EventEmitter, Event, scm, SourceControl, SourceControlInputBox, SourceControlResourceGroup, SourceControlResourceState, SourceControlResourceDecorations, SourceControlInputBoxValidation, Disposable, ProgressLocation, window, workspace, WorkspaceEdit, ThemeColor, DecorationData, Memento, SourceControlInputBoxValidationType, OutputChannel, LogLevel, env, ProgressOptions, CancellationToken } from 'vscode'; import { commands, Uri, Command, EventEmitter, Event, scm, SourceControl, SourceControlInputBox, SourceControlResourceGroup, SourceControlResourceState, SourceControlResourceDecorations, SourceControlInputBoxValidation, Disposable, ProgressLocation, window, workspace, WorkspaceEdit, ThemeColor, Decoration, Memento, SourceControlInputBoxValidationType, OutputChannel, LogLevel, env, ProgressOptions, CancellationToken } from 'vscode';
import { Repository as BaseRepository, Commit, Stash, GitError, Submodule, CommitOptions, ForcePushMode } from './git'; import { Repository as BaseRepository, Commit, Stash, GitError, Submodule, CommitOptions, ForcePushMode } from './git';
import { anyEvent, filterEvent, eventToPromise, dispose, find, isDescendant, IDisposable, onceEvent, EmptyDisposable, debounceEvent, combinedDisposable } from './util'; import { anyEvent, filterEvent, eventToPromise, dispose, find, isDescendant, IDisposable, onceEvent, EmptyDisposable, debounceEvent, combinedDisposable } from './util';
import { memoize, throttle, debounce } from './decorators'; import { memoize, throttle, debounce } from './decorators';
@@ -157,10 +157,7 @@ export class Resource implements SourceControlResourceState {
const tooltip = this.tooltip; const tooltip = this.tooltip;
const strikeThrough = this.strikeThrough; const strikeThrough = this.strikeThrough;
const faded = this.faded; const faded = this.faded;
const letter = this.letter; return { strikeThrough, faded, tooltip, light, dark };
const color = this.color;
return { strikeThrough, faded, tooltip, light, dark, letter, color, source: 'git.resource' /*todo@joh*/ };
} }
get letter(): string { get letter(): string {
@@ -247,12 +244,12 @@ export class Resource implements SourceControlResourceState {
} }
} }
get resourceDecoration(): DecorationData { get resourceDecoration(): Decoration {
const title = this.tooltip; const title = this.tooltip;
const letter = this.letter; const letter = this.letter;
const color = this.color; const color = this.color;
const priority = this.priority; const priority = this.priority;
return { bubble: true, source: 'git.resource', title, letter, color, priority }; return { bubble: true, title, letter, color, priority };
} }
constructor( constructor(

View File

@@ -71,6 +71,7 @@ class SyncStatusBar {
const onEnablementChange = filterEvent(workspace.onDidChangeConfiguration, e => e.affectsConfiguration('git.enableStatusBarSync')); const onEnablementChange = filterEvent(workspace.onDidChangeConfiguration, e => e.affectsConfiguration('git.enableStatusBarSync'));
onEnablementChange(this.updateEnablement, this, this.disposables); onEnablementChange(this.updateEnablement, this, this.disposables);
this.updateEnablement();
this._onDidChange.fire(); this._onDidChange.fire();
} }

View File

@@ -0,0 +1,10 @@
test/**
src/**
tsconfig.json
out/test/**
out/**
extension.webpack.config.js
cgmanifest.json
yarn.lock
preview-src/**
webpack.config.js

View File

@@ -0,0 +1,3 @@
# Image Preview
**Notice:** This extension is bundled with Visual Studio Code. It can be disabled but not uninstalled.

View File

@@ -0,0 +1,20 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
//@ts-check
'use strict';
const withDefaults = require('../shared.webpack.config');
module.exports = withDefaults({
context: __dirname,
resolve: {
mainFields: ['module', 'main']
},
entry: {
extension: './src/extension.ts',
}
});

View File

@@ -0,0 +1,78 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
html, body {
height: 100%;
max-height: 100%;
}
body img {
max-width: none;
max-height: none;
}
.container:focus {
outline: none !important;
}
.container {
padding: 5px 0 0 10px;
box-sizing: border-box;
user-select: none;
}
.container.image {
padding: 0;
display: flex;
box-sizing: border-box;
}
.container.image img {
padding: 0;
background-position: 0 0, 8px 8px;
background-size: 16px 16px;
}
.container.image img {
background-image:
linear-gradient(45deg, rgb(230, 230, 230) 25%, transparent 25%, transparent 75%, rgb(230, 230, 230) 75%, rgb(230, 230, 230)),
linear-gradient(45deg, rgb(230, 230, 230) 25%, transparent 25%, transparent 75%, rgb(230, 230, 230) 75%, rgb(230, 230, 230));
}
.vscode-dark.container.image img {
background-image:
linear-gradient(45deg, rgb(20, 20, 20) 25%, transparent 25%, transparent 75%, rgb(20, 20, 20) 75%, rgb(20, 20, 20)),
linear-gradient(45deg, rgb(20, 20, 20) 25%, transparent 25%, transparent 75%, rgb(20, 20, 20) 75%, rgb(20, 20, 20));
}
.container img.pixelated {
image-rendering: pixelated;
}
.container img.scale-to-fit {
max-width: calc(100% - 20px);
max-height: calc(100% - 20px);
object-fit: contain;
}
.container img {
margin: auto;
}
.container.zoom-in {
cursor: zoom-in;
}
.container.zoom-out {
cursor: zoom-out;
}
.container .embedded-link,
.container .embedded-link:hover {
cursor: pointer;
text-decoration: underline;
margin-left: 5px;
}

View File

@@ -0,0 +1,258 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
// @ts-check
"use strict";
(function () {
/**
* @param {number} value
* @param {number} min
* @param {number} max
* @return {number}
*/
function clamp(value, min, max) {
return Math.min(Math.max(value, min), max);
}
function getSettings() {
const element = document.getElementById('image-preview-settings');
if (element) {
const data = element.getAttribute('data-settings');
if (data) {
return JSON.parse(data);
}
}
throw new Error(`Could not load settings`);
}
/**
* Enable image-rendering: pixelated for images scaled by more than this.
*/
const PIXELATION_THRESHOLD = 3;
const SCALE_PINCH_FACTOR = 0.075;
const MAX_SCALE = 20;
const MIN_SCALE = 0.1;
const zoomLevels = [
0.1,
0.2,
0.3,
0.4,
0.5,
0.6,
0.7,
0.8,
0.9,
1,
1.5,
2,
3,
5,
7,
10,
15,
20
];
const isMac = getSettings().isMac;
const vscode = acquireVsCodeApi();
const initialState = vscode.getState() || { scale: 'fit', offsetX: 0, offsetY: 0 };
// State
let scale = initialState.scale;
let ctrlPressed = false;
let altPressed = false;
// Elements
const container = /** @type {HTMLElement} */(document.querySelector('body'));
const image = document.querySelector('img');
function updateScale(newScale) {
if (!image || !image.parentElement) {
return;
}
if (newScale === 'fit') {
scale = 'fit';
image.classList.add('scale-to-fit');
image.classList.remove('pixelated');
image.style.minWidth = 'auto';
image.style.width = 'auto';
vscode.setState(undefined);
} else {
const oldWidth = image.width;
const oldHeight = image.height;
scale = clamp(newScale, MIN_SCALE, MAX_SCALE);
if (scale >= PIXELATION_THRESHOLD) {
image.classList.add('pixelated');
} else {
image.classList.remove('pixelated');
}
const { scrollTop, scrollLeft } = image.parentElement;
const dx = (scrollLeft + image.parentElement.clientWidth / 2) / image.parentElement.scrollWidth;
const dy = (scrollTop + image.parentElement.clientHeight / 2) / image.parentElement.scrollHeight;
image.classList.remove('scale-to-fit');
image.style.minWidth = `${(image.naturalWidth * scale)}px`;
image.style.width = `${(image.naturalWidth * scale)}px`;
const newWidth = image.width;
const scaleFactor = (newWidth - oldWidth) / oldWidth;
const newScrollLeft = ((oldWidth * scaleFactor * dx) + scrollLeft);
const newScrollTop = ((oldHeight * scaleFactor * dy) + scrollTop);
// scrollbar.setScrollPosition({
// scrollLeft: newScrollLeft,
// scrollTop: newScrollTop,
// });
vscode.setState({ scale: scale, offsetX: newScrollLeft, offsetY: newScrollTop });
}
vscode.postMessage({
type: 'zoom',
value: scale
});
}
function firstZoom() {
if (!image) {
return;
}
scale = image.clientWidth / image.naturalWidth;
updateScale(scale);
}
window.addEventListener('keydown', (/** @type {KeyboardEvent} */ e) => {
if (!image) {
return;
}
ctrlPressed = e.ctrlKey;
altPressed = e.altKey;
if (isMac ? altPressed : ctrlPressed) {
container.classList.remove('zoom-in');
container.classList.add('zoom-out');
}
});
window.addEventListener('keyup', (/** @type {KeyboardEvent} */ e) => {
if (!image) {
return;
}
ctrlPressed = e.ctrlKey;
altPressed = e.altKey;
if (!(isMac ? altPressed : ctrlPressed)) {
container.classList.remove('zoom-out');
container.classList.add('zoom-in');
}
});
container.addEventListener('click', (/** @type {MouseEvent} */ e) => {
if (!image) {
return;
}
if (e.button !== 0) {
return;
}
// left click
if (scale === 'fit') {
firstZoom();
}
if (!(isMac ? altPressed : ctrlPressed)) { // zoom in
let i = 0;
for (; i < zoomLevels.length; ++i) {
if (zoomLevels[i] > scale) {
break;
}
}
updateScale(zoomLevels[i] || MAX_SCALE);
} else {
let i = zoomLevels.length - 1;
for (; i >= 0; --i) {
if (zoomLevels[i] < scale) {
break;
}
}
updateScale(zoomLevels[i] || MIN_SCALE);
}
});
container.addEventListener('wheel', (/** @type {WheelEvent} */ e) => {
if (!image) {
return;
}
const isScrollWheelKeyPressed = isMac ? altPressed : ctrlPressed;
if (!isScrollWheelKeyPressed && !e.ctrlKey) { // pinching is reported as scroll wheel + ctrl
return;
}
e.preventDefault();
e.stopPropagation();
if (scale === 'fit') {
firstZoom();
}
let delta = e.deltaY > 0 ? 1 : -1;
updateScale(scale * (1 - delta * SCALE_PINCH_FACTOR));
});
window.addEventListener('scroll', () => {
if (!image || !image.parentElement || scale === 'fit') {
return;
}
const entry = vscode.getState();
if (entry) {
vscode.setState({ scale: entry.scale, offsetX: window.scrollX, offsetY: window.scrollY });
}
});
container.classList.add('image');
container.classList.add('zoom-in');
image.classList.add('scale-to-fit');
image.style.visibility = 'hidden';
image.addEventListener('load', () => {
if (!image) {
return;
}
vscode.postMessage({
type: 'size',
value: `${image.naturalWidth}x${image.naturalHeight}`,
});
image.style.visibility = 'visible';
updateScale(scale);
if (initialState.scale !== 'fit') {
window.scrollTo(initialState.offsetX, initialState.offsetY);
}
});
window.addEventListener('message', e => {
switch (e.data.type) {
case 'setScale':
updateScale(e.data.scale);
break;
}
});
}());

View File

@@ -0,0 +1,43 @@
{
"name": "image-preview",
"displayName": "%displayName%",
"description": "%description%",
"version": "1.0.0",
"publisher": "vscode",
"enableProposedApi": true,
"license": "MIT",
"aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217",
"engines": {
"vscode": "^1.39.0"
},
"main": "./out/extension",
"categories": [
"Other"
],
"activationEvents": [
"onWebviewEditor:imagePreview.previewEditor"
],
"contributes": {
"webviewEditors": [
{
"viewType": "imagePreview.previewEditor",
"displayName": "%webviewEditors.displayName%",
"selector": [
{
"filenamePattern": "*.{jpg,jpe,jpeg,png,bmp,gif,ico,tga,tif,tiff,webp}"
}
]
}
]
},
"scripts": {
"compile": "gulp compile-extension:image-preview",
"watch": "npm run build-preview && gulp watch-extension:image-preview",
"vscode:prepublish": "npm run build-ext",
"build-ext": "node ../../node_modules/gulp/bin/gulp.js --gulpfile ../../build/gulpfile.extensions.js compile-extension:image-preview ./tsconfig.json"
},
"dependencies": {
"vscode-extension-telemetry": "0.1.1",
"vscode-nls": "^4.0.0"
}
}

View File

@@ -0,0 +1,5 @@
{
"displayName": "Image Preview",
"description": "Previews images.",
"webviewEditors.displayName": "Image Preview"
}

View File

@@ -0,0 +1,42 @@
/*---------------------------------------------------------------------------------------------
* 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';
export function disposeAll(disposables: vscode.Disposable[]) {
while (disposables.length) {
const item = disposables.pop();
if (item) {
item.dispose();
}
}
}
export abstract class Disposable {
private _isDisposed = false;
protected _disposables: vscode.Disposable[] = [];
public dispose(): any {
if (this._isDisposed) {
return;
}
this._isDisposed = true;
disposeAll(this._disposables);
}
protected _register<T extends vscode.Disposable>(value: T): T {
if (this._isDisposed) {
value.dispose();
} else {
this._disposables.push(value);
}
return value;
}
protected get isDisposed() {
return this._isDisposed;
}
}

View File

@@ -0,0 +1,28 @@
/*---------------------------------------------------------------------------------------------
* 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 { Preview } from './preview';
import { SizeStatusBarEntry } from './sizeStatusBarEntry';
import { ZoomStatusBarEntry } from './zoomStatusBarEntry';
export function activate(context: vscode.ExtensionContext) {
const extensionRoot = vscode.Uri.file(context.extensionPath);
const sizeStatusBarEntry = new SizeStatusBarEntry();
context.subscriptions.push(sizeStatusBarEntry);
const zoomStatusBarEntry = new ZoomStatusBarEntry();
context.subscriptions.push(zoomStatusBarEntry);
context.subscriptions.push(vscode.window.registerWebviewEditorProvider(
Preview.viewType,
{
async resolveWebviewEditor(resource: vscode.Uri, editor: vscode.WebviewEditor): Promise<void> {
// tslint:disable-next-line: no-unused-expression
new Preview(extensionRoot, resource, editor, sizeStatusBarEntry, zoomStatusBarEntry);
}
}));
}

View File

@@ -0,0 +1,113 @@
/*---------------------------------------------------------------------------------------------
* 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 { SizeStatusBarEntry } from './sizeStatusBarEntry';
import { ZoomStatusBarEntry } from './zoomStatusBarEntry';
import { Disposable } from './dispose';
export class Preview extends Disposable {
public static readonly viewType = 'imagePreview.previewEditor';
private _active = true;
constructor(
private readonly extensionRoot: vscode.Uri,
resource: vscode.Uri,
private readonly webviewEditor: vscode.WebviewEditor,
private readonly sizeStatusBarEntry: SizeStatusBarEntry,
private readonly zoomStatusBarEntry: ZoomStatusBarEntry,
) {
super();
const resourceRoot = resource.with({
path: resource.path.replace(/\/[^\/]+?\.\w+$/, '/'),
});
webviewEditor.webview.options = {
enableScripts: true,
localResourceRoots: [
resourceRoot,
extensionRoot,
]
};
webviewEditor.webview.html = this.getWebiewContents(webviewEditor, resource);
this._register(webviewEditor.webview.onDidReceiveMessage(message => {
switch (message.type) {
case 'size':
{
this.sizeStatusBarEntry.update(message.value);
break;
}
case 'zoom':
{
this.zoomStatusBarEntry.update(message.value);
break;
}
}
}));
this._register(zoomStatusBarEntry.onDidChangeScale(e => {
this.webviewEditor.webview.postMessage({ type: 'setScale', scale: e.scale });
}));
this._register(webviewEditor.onDidChangeViewState(() => {
this.update();
}));
this._register(webviewEditor.onDidDispose(() => {
if (this._active) {
this.sizeStatusBarEntry.hide();
this.zoomStatusBarEntry.hide();
}
}));
this.update();
}
private update() {
this._active = this.webviewEditor.active;
if (this._active) {
this.sizeStatusBarEntry.show();
this.zoomStatusBarEntry.show();
} else {
this.sizeStatusBarEntry.hide();
this.zoomStatusBarEntry.hide();
}
}
private getWebiewContents(webviewEditor: vscode.WebviewEditor, resource: vscode.Uri): string {
const settings = {
isMac: process.platform === 'darwin'
};
return /* html */`<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Image Preview</title>
<link rel="stylesheet" class="code-user-style" href="${escapeAttribute(this.extensionResource('/media/main.css'))}" type="text/css" media="screen">
<meta id="image-preview-settings" data-settings="${escapeAttribute(JSON.stringify(settings))}">
</head>
<body class="container image scale-to-fit">
<img src="${escapeAttribute(webviewEditor.webview.asWebviewUri(resource))}">
<script src="${escapeAttribute(this.extensionResource('/media/main.js'))}"></script>
</body>
</html>`;
}
private extensionResource(path: string) {
return this.webviewEditor.webview.asWebviewUri(this.extensionRoot.with({
path: this.extensionRoot.path + path
}));
}
}
function escapeAttribute(value: string | vscode.Uri): string {
return value.toString().replace(/"/g, '&quot;');
}

View File

@@ -0,0 +1,33 @@
/*---------------------------------------------------------------------------------------------
* 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 { Disposable } from './dispose';
export class SizeStatusBarEntry extends Disposable {
private readonly _entry: vscode.StatusBarItem;
constructor() {
super();
this._entry = this._register(vscode.window.createStatusBarItem({
id: 'imagePreview.size',
name: 'Image Size',
alignment: vscode.StatusBarAlignment.Right,
priority: 101 /* to the left of editor status (100) */,
}));
}
public show() {
this._entry.show();
}
public hide() {
this._entry.hide();
}
public update(text: string) {
this._entry.text = text;
}
}

View File

@@ -0,0 +1,8 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
/// <reference path='../../../../src/vs/vscode.d.ts'/>
/// <reference path='../../../../src/vs/vscode.proposed.d.ts'/>
/// <reference types='@types/node'/>

View File

@@ -0,0 +1,68 @@
/*---------------------------------------------------------------------------------------------
* 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';
import { Disposable } from './dispose';
const localize = nls.loadMessageBundle();
const selectZoomLevelCommandId = '_imagePreview.selectZoomLevel';
type Scale = number | 'fit';
export class ZoomStatusBarEntry extends Disposable {
private readonly _entry: vscode.StatusBarItem;
private readonly _onDidChangeScale = this._register(new vscode.EventEmitter<{ scale: Scale }>());
public readonly onDidChangeScale = this._onDidChangeScale.event;
constructor() {
super();
this._entry = this._register(vscode.window.createStatusBarItem({
id: 'imagePreview.zoom',
name: 'Image Zoom',
alignment: vscode.StatusBarAlignment.Right,
priority: 102 /* to the left of editor size entry (101) */,
}));
this._register(vscode.commands.registerCommand(selectZoomLevelCommandId, async () => {
type MyPickItem = vscode.QuickPickItem & { scale: Scale };
const scales: Scale[] = [10, 5, 2, 1, 0.5, 0.2, 'fit'];
const options = scales.map((scale): MyPickItem => ({
label: this.zoomLabel(scale),
scale
}));
const pick = await vscode.window.showQuickPick(options, {
placeHolder: localize('zoomStatusBar.placeholder', "Select zoom level")
});
if (pick) {
this._onDidChangeScale.fire({ scale: pick.scale });
}
}));
this._entry.command = selectZoomLevelCommandId;
}
public show() {
this._entry.show();
}
public hide() {
this._entry.hide();
}
public update(scale: Scale) {
this._entry.text = this.zoomLabel(scale);
}
private zoomLabel(scale: Scale): string {
return scale === 'fit'
? localize('zoomStatusBar.wholeImageLabel', "Whole Image")
: `${Math.round(scale * 100)}%`;
}
}

View File

@@ -0,0 +1,10 @@
{
"extends": "../shared.tsconfig.json",
"compilerOptions": {
"outDir": "./out",
"experimentalDecorators": true
},
"include": [
"src/**/*"
]
}

View File

@@ -0,0 +1,46 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
applicationinsights@1.0.8:
version "1.0.8"
resolved "https://registry.yarnpkg.com/applicationinsights/-/applicationinsights-1.0.8.tgz#db6e3d983cf9f9405fe1ee5ba30ac6e1914537b5"
integrity sha512-KzOOGdphOS/lXWMFZe5440LUdFbrLpMvh2SaRxn7BmiI550KAoSb2gIhiq6kJZ9Ir3AxRRztjhzif+e5P5IXIg==
dependencies:
diagnostic-channel "0.2.0"
diagnostic-channel-publishers "0.2.1"
zone.js "0.7.6"
diagnostic-channel-publishers@0.2.1:
version "0.2.1"
resolved "https://registry.yarnpkg.com/diagnostic-channel-publishers/-/diagnostic-channel-publishers-0.2.1.tgz#8e2d607a8b6d79fe880b548bc58cc6beb288c4f3"
integrity sha1-ji1geottef6IC1SLxYzGvrKIxPM=
diagnostic-channel@0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/diagnostic-channel/-/diagnostic-channel-0.2.0.tgz#cc99af9612c23fb1fff13612c72f2cbfaa8d5a17"
integrity sha1-zJmvlhLCP7H/8TYSxy8sv6qNWhc=
dependencies:
semver "^5.3.0"
semver@^5.3.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-5.5.0.tgz#dc4bbc7a6ca9d916dee5d43516f0092b58f7b8ab"
integrity sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA==
vscode-extension-telemetry@0.1.1:
version "0.1.1"
resolved "https://registry.yarnpkg.com/vscode-extension-telemetry/-/vscode-extension-telemetry-0.1.1.tgz#91387e06b33400c57abd48979b0e790415ae110b"
integrity sha512-TkKKG/B/J94DP5qf6xWB4YaqlhWDg6zbbqVx7Bz//stLQNnfE9XS1xm3f6fl24c5+bnEK0/wHgMgZYKIKxPeUA==
dependencies:
applicationinsights "1.0.8"
vscode-nls@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/vscode-nls/-/vscode-nls-4.0.0.tgz#4001c8a6caba5cedb23a9c5ce1090395c0e44002"
integrity sha512-qCfdzcH+0LgQnBpZA53bA32kzp9rpq/f66Som577ObeuDlFIrtbEJ+A/+CCxjIh4G8dpJYNCKIsxpRAHIfsbNw==
zone.js@0.7.6:
version "0.7.6"
resolved "https://registry.yarnpkg.com/zone.js/-/zone.js-0.7.6.tgz#fbbc39d3e0261d0986f1ba06306eb3aeb0d22009"
integrity sha1-+7w50+AmHQmG8boGMG6zrrDSIAk=

View File

@@ -18,8 +18,8 @@ import { Telemetry, LanguageClientErrorHandler } from './telemetry';
import * as Constants from '../constants'; import * as Constants from '../constants';
import { TelemetryFeature, FlatFileImportFeature } from './features'; import { TelemetryFeature, FlatFileImportFeature } from './features';
import * as serviceUtils from './serviceUtils'; import * as serviceUtils from './serviceUtils';
import { promisify } from 'util';
const baseConfig = require('./config.json'); import { readFile } from 'fs';
export class ServiceClient { export class ServiceClient {
private statusView: vscode.StatusBarItem; private statusView: vscode.StatusBarItem;
@@ -28,8 +28,9 @@ export class ServiceClient {
this.statusView = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left); this.statusView = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Left);
} }
public startService(context: vscode.ExtensionContext): Promise<SqlOpsDataClient> { public async startService(context: vscode.ExtensionContext): Promise<SqlOpsDataClient> {
let config: IConfig = JSON.parse(JSON.stringify(baseConfig)); const rawConfig = await promisify(readFile)(path.join(context.extensionPath, 'config.json'));
const config = JSON.parse(rawConfig.toString());
config.installDirectory = path.join(context.extensionPath, config.installDirectory); config.installDirectory = path.join(context.extensionPath, config.installDirectory);
config.proxy = vscode.workspace.getConfiguration('http').get('proxy'); config.proxy = vscode.workspace.getConfiguration('http').get('proxy');
config.strictSSL = vscode.workspace.getConfiguration('http').get('proxyStrictSSL') || true; config.strictSSL = vscode.workspace.getConfiguration('http').get('proxyStrictSSL') || true;
@@ -163,4 +164,3 @@ class CustomOutputChannel implements vscode.OutputChannel {
dispose(): void { dispose(): void {
} }
} }

View File

@@ -6,8 +6,6 @@
import * as path from 'path'; import * as path from 'path';
import * as os from 'os'; import * as os from 'os';
const baseConfig = require('./config.json');
// The function is a duplicate of \src\paths.js. IT would be better to import path.js but it doesn't // The function is a duplicate of \src\paths.js. IT would be better to import path.js but it doesn't
// work for now because the extension is running in different process. // work for now because the extension is running in different process.
export function getAppDataPath(): string { export function getAppDataPath(): string {
@@ -55,25 +53,6 @@ export function verifyPlatform(): Thenable<boolean> {
} }
} }
export function getServiceInstallConfig(basePath?: string): any {
if (!basePath) {
basePath = __dirname;
}
let config = JSON.parse(JSON.stringify(baseConfig));
config.installDirectory = path.join(basePath, config.installDirectory);
return config;
}
export function getResolvedServiceInstallationPath(runtime: Runtime, basePath?: string): string {
let config = getServiceInstallConfig(basePath);
let dir = config.installDirectory;
dir = dir.replace('{#version#}', config.version);
dir = dir.replace('{#platform#}', getRuntimeDisplayName(runtime));
return dir;
}
export function getRuntimeDisplayName(runtime: Runtime): string { export function getRuntimeDisplayName(runtime: Runtime): string {
switch (runtime) { switch (runtime) {
case Runtime.Windows_64: case Runtime.Windows_64:

View File

@@ -95,9 +95,9 @@ export class ModifyColumnsPage extends ImportPage {
title: '' title: ''
} }
], { ], {
horizontal: false, horizontal: false,
componentWidth: '100%' componentWidth: '100%'
}).component(); }).component();
this.loading.component = this.form; this.loading.component = this.form;
await this.view.initializeModel(this.form); await this.view.initializeModel(this.form);

View File

@@ -50,7 +50,7 @@
}, },
"devDependencies": { "devDependencies": {
"@types/chai": "3.4.34", "@types/chai": "3.4.34",
"@types/node": "7.0.43", "@types/node": "^10.14.8",
"adstest": "github:ranasaria/adstest.git#0.0.2", "adstest": "github:ranasaria/adstest.git#0.0.2",
"chai": "3.5.0", "chai": "3.5.0",
"mocha-junit-reporter": "^1.17.0", "mocha-junit-reporter": "^1.17.0",

View File

@@ -7,10 +7,10 @@
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-3.4.34.tgz#d5335792823bb09cddd5e38c3d211b709183854d" resolved "https://registry.yarnpkg.com/@types/chai/-/chai-3.4.34.tgz#d5335792823bb09cddd5e38c3d211b709183854d"
integrity sha1-1TNXkoI7sJzd1eOMPSEbcJGDhU0= integrity sha1-1TNXkoI7sJzd1eOMPSEbcJGDhU0=
"@types/node@7.0.43": "@types/node@^10.14.8":
version "7.0.43" version "10.14.17"
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.43.tgz#a187e08495a075f200ca946079c914e1a5fe962c" resolved "https://registry.yarnpkg.com/@types/node/-/node-10.14.17.tgz#b96d4dd3e427382482848948041d3754d40fd5ce"
integrity sha512-7scYwwfHNppXvH/9JzakbVxk0o0QUILVk1Lv64GRaxwPuGpnF1QBiwdvhDpLcymb8BpomQL3KYoWKq3wUdDMhQ== integrity sha512-p/sGgiPaathCfOtqu2fx5Mu1bcjuP8ALFg4xpGgNkcin7LwRyzUKniEHBKdcE1RPsenq5JVPIpMTJSygLboygQ==
"@types/node@^8.0.47": "@types/node@^8.0.47":
version "8.10.45" version "8.10.45"

View File

@@ -14,7 +14,7 @@
"dependencies": { "dependencies": {
"jsonc-parser": "^2.1.1", "jsonc-parser": "^2.1.1",
"request-light": "^0.2.4", "request-light": "^0.2.4",
"vscode-json-languageservice": "^3.3.1", "vscode-json-languageservice": "^3.3.3",
"vscode-languageserver": "^5.3.0-next.8", "vscode-languageserver": "^5.3.0-next.8",
"vscode-nls": "^4.1.1", "vscode-nls": "^4.1.1",
"vscode-uri": "^2.0.3" "vscode-uri": "^2.0.3"

View File

@@ -312,7 +312,7 @@ function validateTextDocument(textDocument: TextDocument, callback?: (diagnostic
const jsonDocument = getJSONDocument(textDocument); const jsonDocument = getJSONDocument(textDocument);
const version = textDocument.version; const version = textDocument.version;
const documentSettings: DocumentLanguageSettings = textDocument.languageId === 'jsonc' ? { comments: 'ignore', trailingCommas: 'ignore' } : { comments: 'error', trailingCommas: 'error' }; const documentSettings: DocumentLanguageSettings = textDocument.languageId === 'jsonc' ? { comments: 'ignore', trailingCommas: 'warning' } : { comments: 'error', trailingCommas: 'error' };
languageService.doValidation(textDocument, jsonDocument, documentSettings).then(diagnostics => { languageService.doValidation(textDocument, jsonDocument, documentSettings).then(diagnostics => {
setTimeout(() => { setTimeout(() => {
const currDocument = documents.get(textDocument.uri); const currDocument = documents.get(textDocument.uri);

View File

@@ -54,11 +54,6 @@ https-proxy-agent@^2.2.1:
agent-base "^4.1.0" agent-base "^4.1.0"
debug "^3.1.0" debug "^3.1.0"
jsonc-parser@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-2.1.0.tgz#eb0d0c7a3c33048524ce3574c57c7278fb2f1bf3"
integrity sha512-n9GrT8rrr2fhvBbANa1g+xFmgGK5X91KFeDwlKQ3+SJfmH5+tKv/M/kahx/TXOMflfWHKGKqKyfHQaLKTNzJ6w==
jsonc-parser@^2.1.1: jsonc-parser@^2.1.1:
version "2.1.1" version "2.1.1"
resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-2.1.1.tgz#83dc3d7a6e7186346b889b1280eefa04446c6d3e" resolved "https://registry.yarnpkg.com/jsonc-parser/-/jsonc-parser-2.1.1.tgz#83dc3d7a6e7186346b889b1280eefa04446c6d3e"
@@ -78,12 +73,12 @@ request-light@^0.2.4:
https-proxy-agent "^2.2.1" https-proxy-agent "^2.2.1"
vscode-nls "^4.0.0" vscode-nls "^4.0.0"
vscode-json-languageservice@^3.3.1: vscode-json-languageservice@^3.3.3:
version "3.3.1" version "3.3.3"
resolved "https://registry.yarnpkg.com/vscode-json-languageservice/-/vscode-json-languageservice-3.3.1.tgz#4ad2c82db849a7bbe54fcbf5c9b3a2ed26dc8fee" resolved "https://registry.yarnpkg.com/vscode-json-languageservice/-/vscode-json-languageservice-3.3.3.tgz#f7e512a2cd5e82fecbebf507d6fceaea47661297"
integrity sha512-Qyvlrftexu1acvwbMt+CDehVrDZtFV1GAJrKdOCHQL9bWNhzI06KEiSd4iXR0NUOuAdroG/uU4wBkH6e5CcTXg== integrity sha512-5vL3OXTUuQpn6+tGd47dopio+7WwbtIZ07zfYMzAUX8eVWPZjfEsLeSWmQk5Xw+vwgu+j5zC4koz5UofLDGGRA==
dependencies: dependencies:
jsonc-parser "^2.1.0" jsonc-parser "^2.1.1"
vscode-languageserver-types "^3.15.0-next.2" vscode-languageserver-types "^3.15.0-next.2"
vscode-nls "^4.1.1" vscode-nls "^4.1.1"
vscode-uri "^2.0.3" vscode-uri "^2.0.3"

View File

@@ -50,8 +50,7 @@
".babelrc", ".babelrc",
".jsonc", ".jsonc",
".eslintrc", ".eslintrc",
".eslintrc.json", ".eslintrc.json"
"tslint.json"
], ],
"configuration": "./language-configuration.json" "configuration": "./language-configuration.json"
} }

View File

@@ -4,7 +4,7 @@
"If you want to provide a fix or improvement, please create a pull request against the original repository.", "If you want to provide a fix or improvement, please create a pull request against the original repository.",
"Once accepted there, we are happy to receive an update request." "Once accepted there, we are happy to receive an update request."
], ],
"version": "https://github.com/microsoft/vscode-markdown-tm-grammar/commit/eb3898715b50d7911377a650e383a768a3a21f25", "version": "https://github.com/microsoft/vscode-markdown-tm-grammar/commit/00b05ebe6850083664d92d0eba6e5ee8f153baa6",
"name": "Markdown", "name": "Markdown",
"scopeName": "text.html.markdown", "scopeName": "text.html.markdown",
"patterns": [ "patterns": [
@@ -70,11 +70,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -103,11 +103,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -136,11 +136,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -169,11 +169,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -202,11 +202,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -235,11 +235,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -268,11 +268,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -294,18 +294,18 @@
] ]
}, },
"fenced_code_block_r": { "fenced_code_block_r": {
"begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(R|r|s|S|Rprofile)(\\s+[^`~]*)?$)", "begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(R|r|s|S|Rprofile|\\{\\.r.+?\\})(\\s+[^`~]*)?$)",
"name": "markup.fenced_code.block.markdown", "name": "markup.fenced_code.block.markdown",
"end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$", "end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$",
"beginCaptures": { "beginCaptures": {
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -334,11 +334,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -367,11 +367,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -403,11 +403,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -436,11 +436,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -469,11 +469,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -502,11 +502,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -535,11 +535,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -568,11 +568,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -601,11 +601,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -634,11 +634,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -667,11 +667,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -700,11 +700,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -716,7 +716,7 @@
{ {
"begin": "(^|\\G)(\\s*)(.*)", "begin": "(^|\\G)(\\s*)(.*)",
"while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)", "while": "(^|\\G)(?!\\s*([`~]{3,})\\s*$)",
"contentName": "meta.embedded.block.cpp", "contentName": "meta.embedded.block.cpp source.cpp",
"patterns": [ "patterns": [
{ {
"include": "source.cpp" "include": "source.cpp"
@@ -733,11 +733,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -766,11 +766,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -799,11 +799,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -832,11 +832,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -865,11 +865,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -898,11 +898,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -931,11 +931,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -957,18 +957,18 @@
] ]
}, },
"fenced_code_block_js": { "fenced_code_block_js": {
"begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(js|jsx|javascript|es6|mjs)(\\s+[^`~]*)?$)", "begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(js|jsx|javascript|es6|mjs|\\{\\.js.+?\\})(\\s+[^`~]*)?$)",
"name": "markup.fenced_code.block.markdown", "name": "markup.fenced_code.block.markdown",
"end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$", "end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$",
"beginCaptures": { "beginCaptures": {
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -997,11 +997,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -1030,11 +1030,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -1063,11 +1063,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -1096,11 +1096,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -1129,11 +1129,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -1162,11 +1162,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -1195,11 +1195,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -1228,11 +1228,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -1261,11 +1261,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -1287,18 +1287,18 @@
] ]
}, },
"fenced_code_block_python": { "fenced_code_block_python": {
"begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(python|py|py3|rpy|pyw|cpy|SConstruct|Sconstruct|sconstruct|SConscript|gyp|gypi)(\\s+[^`~]*)?$)", "begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(python|py|py3|rpy|pyw|cpy|SConstruct|Sconstruct|sconstruct|SConscript|gyp|gypi|\\{\\.python.+?\\})(\\s+[^`~]*)?$)",
"name": "markup.fenced_code.block.markdown", "name": "markup.fenced_code.block.markdown",
"end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$", "end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$",
"beginCaptures": { "beginCaptures": {
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -1327,11 +1327,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -1353,18 +1353,18 @@
] ]
}, },
"fenced_code_block_rust": { "fenced_code_block_rust": {
"begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(rust|rs)(\\s+[^`~]*)?$)", "begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(rust|rs|\\{\\.rust.+?\\})(\\s+[^`~]*)?$)",
"name": "markup.fenced_code.block.markdown", "name": "markup.fenced_code.block.markdown",
"end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$", "end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$",
"beginCaptures": { "beginCaptures": {
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -1393,11 +1393,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -1419,18 +1419,18 @@
] ]
}, },
"fenced_code_block_shell": { "fenced_code_block_shell": {
"begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(shell|sh|bash|zsh|bashrc|bash_profile|bash_login|profile|bash_logout|.textmate_init)(\\s+[^`~]*)?$)", "begin": "(^|\\G)(\\s*)(`{3,}|~{3,})\\s*(?i:(shell|sh|bash|zsh|bashrc|bash_profile|bash_login|profile|bash_logout|.textmate_init|\\{\\.bash.+?\\})(\\s+[^`~]*)?$)",
"name": "markup.fenced_code.block.markdown", "name": "markup.fenced_code.block.markdown",
"end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$", "end": "(^|\\G)(\\2|\\s{0,3})(\\3)\\s*$",
"beginCaptures": { "beginCaptures": {
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -1459,11 +1459,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -1492,11 +1492,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -1525,11 +1525,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -1558,11 +1558,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -1591,11 +1591,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -1624,11 +1624,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {
@@ -1657,11 +1657,11 @@
"3": { "3": {
"name": "punctuation.definition.markdown" "name": "punctuation.definition.markdown"
}, },
"5": { "4": {
"name": "fenced_code.block.language" "name": "fenced_code.block.language.markdown"
}, },
"6": { "5": {
"name": "fenced_code.block.language.attributes" "name": "fenced_code.block.language.attributes.markdown"
} }
}, },
"endCaptures": { "endCaptures": {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -241,12 +241,6 @@
"description": "%markdown.preview.scrollPreviewWithEditor.desc%", "description": "%markdown.preview.scrollPreviewWithEditor.desc%",
"scope": "resource" "scope": "resource"
}, },
"markdown.preview.scrollPreviewWithEditorSelection": {
"type": "boolean",
"default": true,
"description": "%markdown.preview.scrollPreviewWithEditorSelection.desc%",
"deprecationMessage": "%markdown.preview.scrollPreviewWithEditorSelection.deprecationMessage%"
},
"markdown.preview.markEditorSelection": { "markdown.preview.markEditorSelection": {
"type": "boolean", "type": "boolean",
"default": true, "default": true,
@@ -279,6 +273,20 @@
"%configuration.markdown.preview.openMarkdownLinks.inEditor%" "%configuration.markdown.preview.openMarkdownLinks.inEditor%"
] ]
}, },
"markdown.links.openLocation": {
"type": "string",
"default": "currentGroup",
"description": "%configuration.markdown.links.openLocation.description%",
"scope": "resource",
"enum": [
"currentGroup",
"beside"
],
"enumDescriptions": [
"%configuration.markdown.links.openLocation.currentGroup%",
"%configuration.markdown.links.openLocation.beside%"
]
},
"markdown.trace": { "markdown.trace": {
"type": "string", "type": "string",
"enum": [ "enum": [

View File

@@ -10,8 +10,6 @@
"markdown.preview.markEditorSelection.desc": "Mark the current editor selection in the markdown preview.", "markdown.preview.markEditorSelection.desc": "Mark the current editor selection in the markdown preview.",
"markdown.preview.scrollEditorWithPreview.desc": "When a markdown preview is scrolled, update the view of the editor.", "markdown.preview.scrollEditorWithPreview.desc": "When a markdown preview is scrolled, update the view of the editor.",
"markdown.preview.scrollPreviewWithEditor.desc": "When a markdown editor is scrolled, update the view of the preview.", "markdown.preview.scrollPreviewWithEditor.desc": "When a markdown editor is scrolled, update the view of the preview.",
"markdown.preview.scrollPreviewWithEditorSelection.desc": "[Deprecated] Scrolls the markdown preview to reveal the currently selected line from the editor.",
"markdown.preview.scrollPreviewWithEditorSelection.deprecationMessage": "This setting has been replaced by 'markdown.preview.scrollPreviewWithEditor' and no longer has any effect.",
"markdown.preview.title": "Open Preview", "markdown.preview.title": "Open Preview",
"markdown.previewSide.title": "Open Preview to the Side", "markdown.previewSide.title": "Open Preview to the Side",
"markdown.showLockedPreviewToSide.title": "Open Locked Preview to the Side", "markdown.showLockedPreviewToSide.title": "Open Locked Preview to the Side",
@@ -21,7 +19,10 @@
"markdown.trace.desc": "Enable debug logging for the markdown extension.", "markdown.trace.desc": "Enable debug logging for the markdown extension.",
"markdown.preview.refresh.title": "Refresh Preview", "markdown.preview.refresh.title": "Refresh Preview",
"markdown.preview.toggleLock.title": "Toggle Preview Locking", "markdown.preview.toggleLock.title": "Toggle Preview Locking",
"configuration.markdown.preview.openMarkdownLinks.description": "How should clicking on links to markdown files be handled in the preview.", "configuration.markdown.preview.openMarkdownLinks.description": "Controls how links to other markdown files in the markdown preview should be opened.",
"configuration.markdown.preview.openMarkdownLinks.inEditor": "Try to open links in the editor", "configuration.markdown.preview.openMarkdownLinks.inEditor": "Try to open links in the editor",
"configuration.markdown.preview.openMarkdownLinks.inPreview": "Try to open links in the markdown preview" "configuration.markdown.preview.openMarkdownLinks.inPreview": "Try to open links in the markdown preview",
} "configuration.markdown.links.openLocation.description": "Controls where links in markdown files should be opened.",
"configuration.markdown.links.openLocation.currentGroup": "Open links in the active editor group.",
"configuration.markdown.links.openLocation.beside": "Open links beside the active editor."
}

View File

@@ -1,13 +1,7 @@
{ {
"extends": "../../shared.tsconfig.json",
"compilerOptions": { "compilerOptions": {
"outDir": "./dist/", "outDir": "./dist/",
"module": "commonjs", "jsx": "react"
"target": "es6",
"jsx": "react",
"sourceMap": true,
"strict": true,
"strictBindCallApply": true,
"noImplicitAny": true,
"noUnusedLocals": true
} }
} }

View File

@@ -13,8 +13,14 @@ import { isMarkdownFile } from '../util/file';
export interface OpenDocumentLinkArgs { export interface OpenDocumentLinkArgs {
path: string; readonly path: string;
fragment: string; readonly fragment: string;
readonly fromResource: any;
}
enum OpenMarkdownLinks {
beside = 'beside',
currentGroup = 'currentGroup',
} }
export class OpenDocumentLinkCommand implements Command { export class OpenDocumentLinkCommand implements Command {
@@ -22,10 +28,15 @@ export class OpenDocumentLinkCommand implements Command {
public readonly id = OpenDocumentLinkCommand.id; public readonly id = OpenDocumentLinkCommand.id;
public static createCommandUri( public static createCommandUri(
fromResource: vscode.Uri,
path: string, path: string,
fragment: string fragment: string,
): vscode.Uri { ): vscode.Uri {
return vscode.Uri.parse(`command:${OpenDocumentLinkCommand.id}?${encodeURIComponent(JSON.stringify({ path: encodeURIComponent(path), fragment }))}`); return vscode.Uri.parse(`command:${OpenDocumentLinkCommand.id}?${encodeURIComponent(JSON.stringify(<OpenDocumentLinkArgs>{
path: encodeURIComponent(path),
fragment,
fromResource: encodeURIComponent(fromResource.toString(true)),
}))}`);
} }
public constructor( public constructor(
@@ -33,30 +44,45 @@ export class OpenDocumentLinkCommand implements Command {
) { } ) { }
public execute(args: OpenDocumentLinkArgs) { public execute(args: OpenDocumentLinkArgs) {
const p = decodeURIComponent(args.path); const fromResource = vscode.Uri.parse(decodeURIComponent(args.fromResource));
return this.tryOpen(p, args).catch(() => { const targetPath = decodeURIComponent(args.path);
if (p && extname(p) === '') { const column = this.getViewColumn(fromResource);
return this.tryOpen(p + '.md', args); return this.tryOpen(targetPath, args, column).catch(() => {
if (targetPath && extname(targetPath) === '') {
return this.tryOpen(targetPath + '.md', args, column);
} }
const resource = vscode.Uri.file(p); const targetResource = vscode.Uri.file(targetPath);
return Promise.resolve(undefined) return Promise.resolve(undefined)
.then(() => vscode.commands.executeCommand('vscode.open', resource)) .then(() => vscode.commands.executeCommand('vscode.open', targetResource, column))
.then(() => undefined); .then(() => undefined);
}); });
} }
private async tryOpen(path: string, args: OpenDocumentLinkArgs) { private async tryOpen(path: string, args: OpenDocumentLinkArgs, column: vscode.ViewColumn) {
const resource = vscode.Uri.file(path); const resource = vscode.Uri.file(path);
if (vscode.window.activeTextEditor && isMarkdownFile(vscode.window.activeTextEditor.document)) { if (vscode.window.activeTextEditor && isMarkdownFile(vscode.window.activeTextEditor.document)) {
if (!path || vscode.window.activeTextEditor.document.uri.fsPath === resource.fsPath) { if (!path || vscode.window.activeTextEditor.document.uri.fsPath === resource.fsPath) {
return this.tryRevealLine(vscode.window.activeTextEditor, args.fragment); return this.tryRevealLine(vscode.window.activeTextEditor, args.fragment);
} }
} }
return vscode.workspace.openTextDocument(resource) return vscode.workspace.openTextDocument(resource)
.then(vscode.window.showTextDocument) .then(document => vscode.window.showTextDocument(document, column))
.then(editor => this.tryRevealLine(editor, args.fragment)); .then(editor => this.tryRevealLine(editor, args.fragment));
} }
private getViewColumn(resource: vscode.Uri): vscode.ViewColumn {
const config = vscode.workspace.getConfiguration('markdown', resource);
const openLinks = config.get<OpenMarkdownLinks>('links.openLocation', OpenMarkdownLinks.currentGroup);
switch (openLinks) {
case OpenMarkdownLinks.beside:
return vscode.ViewColumn.Beside;
case OpenMarkdownLinks.currentGroup:
default:
return vscode.ViewColumn.Active;
}
}
private async tryRevealLine(editor: vscode.TextEditor, fragment?: string) { private async tryRevealLine(editor: vscode.TextEditor, fragment?: string) {
if (editor && fragment) { if (editor && fragment) {
const toc = new TableOfContentsProvider(this.engine, editor.document); const toc = new TableOfContentsProvider(this.engine, editor.document);
@@ -107,4 +133,4 @@ async function tryResolveLinkToMarkdownFile(path: string): Promise<vscode.Uri |
return document.uri; return document.uri;
} }
return undefined; return undefined;
} }

View File

@@ -0,0 +1,50 @@
/*---------------------------------------------------------------------------------------------
* 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 { Disposable } from './util/dispose';
export class DocumentIndex extends Disposable {
private readonly _uriMap = new Map();
constructor() {
super();
for (let doc of vscode.workspace.textDocuments) {
this._registerDoc(doc);
}
this._register(
vscode.workspace.onDidOpenTextDocument((doc) => {
this._registerDoc(doc);
})
);
this._register(
vscode.workspace.onDidCloseTextDocument((doc) => {
this._unregisterDoc(doc.uri);
})
);
}
getByUri(uri: vscode.Uri): vscode.TextDocument | undefined {
return this._uriMap.get(uri.toString());
}
private _registerDoc(doc: vscode.TextDocument) {
const uri = doc.uri.toString();
if (this._uriMap.has(uri)) {
throw new Error(`The document ${uri} is already registered.`);
}
this._uriMap.set(uri, doc);
}
private _unregisterDoc(uri: vscode.Uri) {
if (!this._uriMap.has(uri.toString())) {
throw new Error(`The document ${uri.toString()} is not registered.`);
}
this._uriMap.delete(uri.toString());
}
}

View File

@@ -38,7 +38,7 @@ function parseLink(
} }
return { return {
uri: OpenDocumentLinkCommand.createCommandUri(resourcePath, tempUri.fragment), uri: OpenDocumentLinkCommand.createCommandUri(document.uri, resourcePath, tempUri.fragment),
tooltip: localize('documentLink.tooltip', 'Follow link') tooltip: localize('documentLink.tooltip', 'Follow link')
}; };
} }
@@ -183,4 +183,4 @@ export default class LinkProvider implements vscode.DocumentLinkProvider {
} }
return out; return out;
} }
} }

Some files were not shown because too many files have changed in this diff Show More