Revert "Revert "Merge from vscode ada4bddb8edc69eea6ebaaa0e88c5f903cbd43d8 (#5529)" (#5553)" (#5562)

This reverts commit c9a4f8f664.
This commit is contained in:
Anthony Dresser
2019-05-21 14:19:32 -07:00
committed by GitHub
parent 7670104e4d
commit 81ae86ff79
325 changed files with 4497 additions and 3328 deletions

126
build/.nativeignore Normal file
View File

@@ -0,0 +1,126 @@
# cleanup rules for native node modules, .gitignore style
fsevents/binding.gyp
fsevents/fsevents.cc
fsevents/build/**
fsevents/src/**
fsevents/test/**
!fsevents/**/*.node
vscode-sqlite3/binding.gyp
vscode-sqlite3/benchmark/**
vscode-sqlite3/cloudformation/**
vscode-sqlite3/deps/**
vscode-sqlite3/test/**
vscode-sqlite3/build/**
vscode-sqlite3/src/**
!vscode-sqlite3/build/Release/*.node
oniguruma/binding.gyp
oniguruma/build/**
oniguruma/src/**
oniguruma/deps/**
!oniguruma/build/Release/*.node
!oniguruma/src/*.js
windows-mutex/binding.gyp
windows-mutex/build/**
windows-mutex/src/**
!windows-mutex/**/*.node
native-keymap/binding.gyp
native-keymap/build/**
native-keymap/src/**
native-keymap/deps/**
!native-keymap/build/Release/*.node
native-is-elevated/binding.gyp
native-is-elevated/build/**
native-is-elevated/src/**
native-is-elevated/deps/**
!native-is-elevated/build/Release/*.node
native-watchdog/binding.gyp
native-watchdog/build/**
native-watchdog/src/**
!native-watchdog/build/Release/*.node
spdlog/binding.gyp
spdlog/build/**
spdlog/deps/**
spdlog/src/**
spdlog/test/**
!spdlog/build/Release/*.node
jschardet/dist/**
windows-foreground-love/binding.gyp
windows-foreground-love/build/**
windows-foreground-love/src/**
!windows-foreground-love/**/*.node
windows-process-tree/binding.gyp
windows-process-tree/build/**
windows-process-tree/src/**
!windows-process-tree/**/*.node
gc-signals/binding.gyp
gc-signals/build/**
gc-signals/src/**
gc-signals/deps/**
!gc-signals/build/Release/*.node
!gc-signals/src/index.js
keytar/binding.gyp
keytar/build/**
keytar/src/**
keytar/script/**
keytar/node_modules/**
!keytar/**/*.node
node-pty/binding.gyp
node-pty/build/**
node-pty/src/**
node-pty/tools/**
!node-pty/build/Release/*.exe
!node-pty/build/Release/*.dll
!node-pty/build/Release/*.node
chart.js/node_modules/**
emmet/node_modules/**
pty.js/build/**
!pty.js/build/Release/**
jquery-ui/external/**
jquery-ui/demos/**
core-js/**/**
slickgrid/node_modules/**
slickgrid/examples/**
vscode-nsfw/binding.gyp
vscode-nsfw/build/**
vscode-nsfw/src/**
vscode-nsfw/openpa/**
vscode-nsfw/includes/**
!vscode-nsfw/build/Release/*.node
!vscode-nsfw/**/*.a
vsda/binding.gyp
vsda/README.md
vsda/build/**
vsda/*.bat
vsda/*.sh
vsda/*.cpp
vsda/*.h
!vsda/build/Release/vsda.node
vscode-windows-ca-certs/**/*
!vscode-windows-ca-certs/package.json
!vscode-windows-ca-certs/**/*.node
node-addon-api/**/*

View File

@@ -7,15 +7,21 @@ steps:
inputs: inputs:
versionSpec: "1.10.1" versionSpec: "1.10.1"
- task: AzureKeyVault@1
displayName: 'Azure Key Vault: Get Secrets'
inputs:
azureSubscription: 'vscode-builds-subscription'
KeyVaultName: vscode
- script: | - script: |
set -e set -e
cat << EOF > ~/.netrc cat << EOF > ~/.netrc
machine monacotools.visualstudio.com machine monacotools.visualstudio.com
password $(VSO_PAT) password $(devops-pat)
machine github.com machine github.com
login vscode login vscode
password $(VSCODE_MIXIN_PASSWORD) password $(github-distro-mixin-password)
EOF EOF
git config user.email "vscode@microsoft.com" git config user.email "vscode@microsoft.com"
@@ -34,8 +40,8 @@ steps:
- script: | - script: |
set -e set -e
VSCODE_MIXIN_PASSWORD="$(VSCODE_MIXIN_PASSWORD)" \ VSCODE_MIXIN_PASSWORD="$(github-distro-mixin-password)" \
AZURE_STORAGE_ACCESS_KEY="$(AZURE_STORAGE_ACCESS_KEY)" \ AZURE_STORAGE_ACCESS_KEY="$(ticino-storage-key)" \
./build/azure-pipelines/darwin/build.sh ./build/azure-pipelines/darwin/build.sh
displayName: Build displayName: Build
@@ -77,11 +83,11 @@ steps:
- script: | - script: |
set -e set -e
VSCODE_MIXIN_PASSWORD="$(VSCODE_MIXIN_PASSWORD)" \ VSCODE_MIXIN_PASSWORD="$(github-distro-mixin-password)" \
AZURE_DOCUMENTDB_MASTERKEY="$(AZURE_DOCUMENTDB_MASTERKEY)" \ AZURE_DOCUMENTDB_MASTERKEY="$(builds-docdb-key-readwrite)" \
AZURE_STORAGE_ACCESS_KEY="$(AZURE_STORAGE_ACCESS_KEY)" \ AZURE_STORAGE_ACCESS_KEY="$(ticino-storage-key)" \
AZURE_STORAGE_ACCESS_KEY_2="$(AZURE_STORAGE_ACCESS_KEY_2)" \ AZURE_STORAGE_ACCESS_KEY_2="$(vscode-storage-key)" \
VSCODE_HOCKEYAPP_TOKEN="$(VSCODE_HOCKEYAPP_TOKEN)" \ VSCODE_HOCKEYAPP_TOKEN="$(vscode-hockeyapp-token)" \
./build/azure-pipelines/darwin/publish.sh ./build/azure-pipelines/darwin/publish.sh
displayName: Publish displayName: Publish

View File

@@ -10,13 +10,19 @@ steps:
inputs: inputs:
versionSpec: "10.15.1" versionSpec: "10.15.1"
- task: AzureKeyVault@1
displayName: 'Azure Key Vault: Get Secrets'
inputs:
azureSubscription: 'vscode-builds-subscription'
KeyVaultName: vscode
- script: | - script: |
set -e set -e
cat << EOF > ~/.netrc cat << EOF > ~/.netrc
machine github.com machine github.com
login vscode login vscode
password $(VSCODE_MIXIN_PASSWORD) password $(github-distro-mixin-password)
EOF EOF
git config user.email "vscode@microsoft.com" git config user.email "vscode@microsoft.com"

View File

@@ -7,6 +7,12 @@ steps:
inputs: inputs:
versionSpec: "1.10.1" versionSpec: "1.10.1"
- task: AzureKeyVault@1
displayName: 'Azure Key Vault: Get Secrets'
inputs:
azureSubscription: 'vscode-builds-subscription'
KeyVaultName: vscode
- script: | - script: |
set -e set -e
export npm_config_arch="$(VSCODE_ARCH)" export npm_config_arch="$(VSCODE_ARCH)"
@@ -16,10 +22,10 @@ steps:
cat << EOF > ~/.netrc cat << EOF > ~/.netrc
machine monacotools.visualstudio.com machine monacotools.visualstudio.com
password $(VSO_PAT) password $(devops-pat)
machine github.com machine github.com
login vscode login vscode
password $(VSCODE_MIXIN_PASSWORD) password $(github-distro-mixin-password)
EOF EOF
git config user.email "vscode@microsoft.com" git config user.email "vscode@microsoft.com"
@@ -38,7 +44,7 @@ steps:
- script: | - script: |
set -e set -e
VSCODE_MIXIN_PASSWORD="$(VSCODE_MIXIN_PASSWORD)" \ VSCODE_MIXIN_PASSWORD="$(github-distro-mixin-password)" \
./build/azure-pipelines/linux/build.sh ./build/azure-pipelines/linux/build.sh
displayName: Build displayName: Build
@@ -55,10 +61,10 @@ steps:
- script: | - script: |
set -e set -e
AZURE_DOCUMENTDB_MASTERKEY="$(AZURE_DOCUMENTDB_MASTERKEY)" \ AZURE_DOCUMENTDB_MASTERKEY="$(builds-docdb-key-readwrite)" \
AZURE_STORAGE_ACCESS_KEY_2="$(AZURE_STORAGE_ACCESS_KEY_2)" \ AZURE_STORAGE_ACCESS_KEY_2="$(vscode-storage-key)" \
VSCODE_MIXIN_PASSWORD="$(VSCODE_MIXIN_PASSWORD)" \ VSCODE_MIXIN_PASSWORD="$(github-distro-mixin-password)" \
VSCODE_HOCKEYAPP_TOKEN="$(VSCODE_HOCKEYAPP_TOKEN)" \ VSCODE_HOCKEYAPP_TOKEN="$(vscode-hockeyapp-token)" \
./build/azure-pipelines/linux/publish.sh ./build/azure-pipelines/linux/publish.sh
displayName: Publish displayName: Publish

View File

@@ -7,6 +7,12 @@ steps:
inputs: inputs:
versionSpec: "1.10.1" versionSpec: "1.10.1"
- task: AzureKeyVault@1
displayName: 'Azure Key Vault: Get Secrets'
inputs:
azureSubscription: 'vscode-builds-subscription'
KeyVaultName: vscode
- task: DownloadPipelineArtifact@0 - task: DownloadPipelineArtifact@0
displayName: 'Download Pipeline Artifact' displayName: 'Download Pipeline Artifact'
inputs: inputs:
@@ -44,6 +50,6 @@ steps:
(cd $SNAP_ROOT/code-* && sudo snapcraft snap --output "$SNAP_PATH") (cd $SNAP_ROOT/code-* && sudo snapcraft snap --output "$SNAP_PATH")
# Publish snap package # Publish snap package
AZURE_DOCUMENTDB_MASTERKEY="$(AZURE_DOCUMENTDB_MASTERKEY)" \ AZURE_DOCUMENTDB_MASTERKEY="$(builds-docdb-key-readwrite)" \
AZURE_STORAGE_ACCESS_KEY_2="$(AZURE_STORAGE_ACCESS_KEY_2)" \ AZURE_STORAGE_ACCESS_KEY_2="$(vscode-storage-key)" \
node build/azure-pipelines/common/publish.js "$VSCODE_QUALITY" "linux-snap-$ARCH" package "$SNAP_FILENAME" "$VERSION" true "$SNAP_PATH" node build/azure-pipelines/common/publish.js "$VSCODE_QUALITY" "linux-snap-$ARCH" package "$SNAP_FILENAME" "$VERSION" true "$SNAP_PATH"

View File

@@ -1,9 +1,11 @@
resources: resources:
containers: containers:
- container: vscode-x64 - container: vscode-x64
image: joaomoreno/vscode-linux-build-agent:x64 endpoint: VSCodeHub
image: vscodehub.azurecr.io/vscode-linux-build-agent:x64
- container: vscode-ia32 - container: vscode-ia32
image: joaomoreno/vscode-linux-build-agent:ia32 endpoint: VSCodeHub
image: vscodehub.azurecr.io/vscode-linux-build-agent:ia32
- container: snapcraft - container: snapcraft
image: snapcore/snapcraft image: snapcore/snapcraft

View File

@@ -7,12 +7,18 @@ steps:
inputs: inputs:
versionSpec: "1.10.1" versionSpec: "1.10.1"
- task: AzureKeyVault@1
displayName: 'Azure Key Vault: Get Secrets'
inputs:
azureSubscription: 'vscode-builds-subscription'
KeyVaultName: vscode
- script: | - script: |
set -e set -e
(cd build ; yarn) (cd build ; yarn)
AZURE_DOCUMENTDB_MASTERKEY="$(AZURE_DOCUMENTDB_MASTERKEY)" \ AZURE_DOCUMENTDB_MASTERKEY="$(builds-docdb-key-readwrite)" \
AZURE_STORAGE_ACCESS_KEY_2="$(AZURE_STORAGE_ACCESS_KEY_2)" \ AZURE_STORAGE_ACCESS_KEY_2="$(vscode-storage-key)" \
MOONCAKE_STORAGE_ACCESS_KEY="$(MOONCAKE_STORAGE_ACCESS_KEY)" \ MOONCAKE_STORAGE_ACCESS_KEY="$(vscode-mooncake-storage-key)" \
node build/azure-pipelines/common/sync-mooncake.js "$VSCODE_QUALITY" node build/azure-pipelines/common/sync-mooncake.js "$VSCODE_QUALITY"

View File

@@ -12,10 +12,16 @@ steps:
versionSpec: '2.x' versionSpec: '2.x'
addToPath: true addToPath: true
- task: AzureKeyVault@1
displayName: 'Azure Key Vault: Get Secrets'
inputs:
azureSubscription: 'vscode-builds-subscription'
KeyVaultName: vscode
- powershell: | - powershell: |
. build/azure-pipelines/win32/exec.ps1 . build/azure-pipelines/win32/exec.ps1
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
"machine monacotools.visualstudio.com`npassword $(VSO_PAT)`nmachine github.com`nlogin vscode`npassword $(VSCODE_MIXIN_PASSWORD)" | Out-File "$env:USERPROFILE\_netrc" -Encoding ASCII "machine monacotools.visualstudio.com`npassword $(devops-pat)`nmachine github.com`nlogin vscode`npassword $(github-distro-mixin-password)" | Out-File "$env:USERPROFILE\_netrc" -Encoding ASCII
$env:npm_config_arch="$(VSCODE_ARCH)" $env:npm_config_arch="$(VSCODE_ARCH)"
$env:CHILD_CONCURRENCY="1" $env:CHILD_CONCURRENCY="1"
@@ -36,7 +42,7 @@ steps:
- powershell: | - powershell: |
. build/azure-pipelines/win32/exec.ps1 . build/azure-pipelines/win32/exec.ps1
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
$env:VSCODE_MIXIN_PASSWORD="$(VSCODE_MIXIN_PASSWORD)" $env:VSCODE_MIXIN_PASSWORD="$(github-distro-mixin-password)"
.\build\azure-pipelines\win32\build.ps1 .\build\azure-pipelines\win32\build.ps1
displayName: Build displayName: Build
@@ -126,15 +132,15 @@ steps:
- powershell: | - powershell: |
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
.\build\azure-pipelines\win32\import-esrp-auth-cert.ps1 -AuthCertificateBase64 $(ESRP_AUTH_CERTIFICATE) -AuthCertificateKey $(ESRP_AUTH_CERTIFICATE_KEY) .\build\azure-pipelines\win32\import-esrp-auth-cert.ps1 -AuthCertificateBase64 $(esrp-auth-certificate) -AuthCertificateKey $(esrp-auth-certificate-key)
displayName: Import ESRP Auth Certificate displayName: Import ESRP Auth Certificate
- powershell: | - powershell: |
. build/azure-pipelines/win32/exec.ps1 . build/azure-pipelines/win32/exec.ps1
$ErrorActionPreference = "Stop" $ErrorActionPreference = "Stop"
$env:AZURE_STORAGE_ACCESS_KEY_2 = "$(AZURE_STORAGE_ACCESS_KEY_2)" $env:AZURE_STORAGE_ACCESS_KEY_2 = "$(vscode-storage-key)"
$env:AZURE_DOCUMENTDB_MASTERKEY = "$(AZURE_DOCUMENTDB_MASTERKEY)" $env:AZURE_DOCUMENTDB_MASTERKEY = "$(builds-docdb-key-readwrite)"
$env:VSCODE_HOCKEYAPP_TOKEN = "$(VSCODE_HOCKEYAPP_TOKEN)" $env:VSCODE_HOCKEYAPP_TOKEN = "$(vscode-hockeyapp-token)"
.\build\azure-pipelines\win32\publish.ps1 .\build\azure-pipelines\win32\publish.ps1
displayName: Publish displayName: Publish

View File

@@ -335,33 +335,7 @@ function packageTask(platform, arch, sourceFolderName, destinationFolderName, op
const deps = gulp.src(depsSrc, { base: '.', dot: true }) const deps = gulp.src(depsSrc, { base: '.', dot: true })
.pipe(filter(['**', '!**/package-lock.json'])) .pipe(filter(['**', '!**/package-lock.json']))
.pipe(util.cleanNodeModule('fsevents', ['binding.gyp', 'fsevents.cc', 'build/**', 'src/**', 'test/**'], ['**/*.node'])) .pipe(util.cleanNodeModules(path.join(__dirname, '.nativeignore')))
.pipe(util.cleanNodeModule('vscode-sqlite3', ['binding.gyp', 'benchmark/**', 'cloudformation/**', 'deps/**', 'test/**', 'build/**', 'src/**'], ['build/Release/*.node']))
.pipe(util.cleanNodeModule('oniguruma', ['binding.gyp', 'build/**', 'src/**', 'deps/**'], ['build/Release/*.node', 'src/*.js']))
.pipe(util.cleanNodeModule('windows-mutex', ['binding.gyp', 'build/**', 'src/**'], ['**/*.node']))
.pipe(util.cleanNodeModule('native-keymap', ['binding.gyp', 'build/**', 'src/**', 'deps/**'], ['build/Release/*.node']))
.pipe(util.cleanNodeModule('native-is-elevated', ['binding.gyp', 'build/**', 'src/**', 'deps/**'], ['build/Release/*.node']))
.pipe(util.cleanNodeModule('native-watchdog', ['binding.gyp', 'build/**', 'src/**'], ['build/Release/*.node']))
.pipe(util.cleanNodeModule('spdlog', ['binding.gyp', 'build/**', 'deps/**', 'src/**', 'test/**'], ['build/Release/*.node']))
.pipe(util.cleanNodeModule('jschardet', ['dist/**']))
.pipe(util.cleanNodeModule('windows-foreground-love', ['binding.gyp', 'build/**', 'src/**'], ['**/*.node']))
.pipe(util.cleanNodeModule('windows-process-tree', ['binding.gyp', 'build/**', 'src/**'], ['**/*.node']))
.pipe(util.cleanNodeModule('gc-signals', ['binding.gyp', 'build/**', 'src/**', 'deps/**'], ['build/Release/*.node', 'src/index.js']))
.pipe(util.cleanNodeModule('keytar', ['binding.gyp', 'build/**', 'src/**', 'script/**', 'node_modules/**'], ['**/*.node']))
.pipe(util.cleanNodeModule('node-pty', ['binding.gyp', 'build/**', 'src/**', 'tools/**'], ['build/Release/*.exe', 'build/Release/*.dll', 'build/Release/*.node']))
// {{SQL CARBON EDIT}}
.pipe(util.cleanNodeModule('chart.js', ['node_modules/**'], undefined))
.pipe(util.cleanNodeModule('emmet', ['node_modules/**'], undefined))
.pipe(util.cleanNodeModule('pty.js', ['build/**'], ['build/Release/**']))
.pipe(util.cleanNodeModule('jquery-ui', ['external/**', 'demos/**'], undefined))
.pipe(util.cleanNodeModule('core-js', ['**/**'], undefined))
.pipe(util.cleanNodeModule('slickgrid', ['node_modules/**', 'examples/**'], undefined))
.pipe(util.cleanNodeModule('nsfw', ['binding.gyp', 'build/**', 'src/**', 'openpa/**', 'includes/**'], ['**/*.node', '**/*.a']))
.pipe(util.cleanNodeModule('vscode-nsfw', ['binding.gyp', 'build/**', 'src/**', 'openpa/**', 'includes/**'], ['build/Release/*.node', '**/*.a']))
// {{SQL CARBON EDIT}} - End
.pipe(util.cleanNodeModule('vsda', ['binding.gyp', 'README.md', 'build/**', '*.bat', '*.sh', '*.cpp', '*.h'], ['build/Release/vsda.node']))
.pipe(util.cleanNodeModule('vscode-windows-ca-certs', ['**/*'], ['package.json', '**/*.node']))
.pipe(util.cleanNodeModule('node-addon-api', ['**/*']))
.pipe(createAsar(path.join(process.cwd(), 'node_modules'), ['**/*.node', '**/vscode-ripgrep/bin/*', '**/node-pty/build/Release/*'], 'app/node_modules.asar')); .pipe(createAsar(path.join(process.cwd(), 'node_modules'), ['**/*.node', '**/vscode-ripgrep/bin/*', '**/node-pty/build/Release/*'], 'app/node_modules.asar'));
// {{SQL CARBON EDIT}} // {{SQL CARBON EDIT}}
@@ -380,7 +354,7 @@ function packageTask(platform, arch, sourceFolderName, destinationFolderName, op
], { base: '.', dot: true }); ], { base: '.', dot: true });
let all = es.merge( let all = es.merge(
packageJsonStream, packageJsonStream,
productJsonStream, productJsonStream,
license, license,
api, api,

View File

@@ -306,9 +306,7 @@ function packageExtensionsStream(optsIn) {
..._.flatten(extensionsProductionDependencies.map((d) => path.relative(root, d.path)).map((d) => [`${d}/**`, `!${d}/**/{test,tests}/**`])), ..._.flatten(extensionsProductionDependencies.map((d) => path.relative(root, d.path)).map((d) => [`${d}/**`, `!${d}/**/{test,tests}/**`])),
]; ];
const localExtensionDependencies = () => gulp.src(extensionDepsSrc, { base: '.', dot: true }) const localExtensionDependencies = () => gulp.src(extensionDepsSrc, { base: '.', dot: true })
.pipe(filter(['**', '!**/package-lock.json'])) .pipe(filter(['**', '!**/package-lock.json']));
.pipe(util2.cleanNodeModule('account-provider-azure', ['node_modules/date-utils/doc/**', 'node_modules/adal_node/node_modules/**'], undefined))
.pipe(util2.cleanNodeModule('typescript', ['**/**'], undefined));
// Original code commented out here // Original code commented out here
// const localExtensionDependencies = () => gulp.src('extensions/node_modules/**', { base: '.' }); // const localExtensionDependencies = () => gulp.src('extensions/node_modules/**', { base: '.' });
// const marketplaceExtensions = () => es.merge( // const marketplaceExtensions = () => es.merge(

View File

@@ -370,8 +370,6 @@ export function packageExtensionsStream(optsIn?: IPackageExtensionsOptions): Nod
const localExtensionDependencies = () => gulp.src(extensionDepsSrc, { base: '.', dot: true }) const localExtensionDependencies = () => gulp.src(extensionDepsSrc, { base: '.', dot: true })
.pipe(filter(['**', '!**/package-lock.json'])) .pipe(filter(['**', '!**/package-lock.json']))
.pipe(util2.cleanNodeModule('account-provider-azure', ['node_modules/date-utils/doc/**', 'node_modules/adal_node/node_modules/**'], undefined))
.pipe(util2.cleanNodeModule('typescript', ['**/**'], undefined));
// Original code commented out here // Original code commented out here
// const localExtensionDependencies = () => gulp.src('extensions/node_modules/**', { base: '.' }); // const localExtensionDependencies = () => gulp.src('extensions/node_modules/**', { base: '.' });

View File

@@ -8,7 +8,6 @@ const es = require("event-stream");
const debounce = require("debounce"); const debounce = require("debounce");
const _filter = require("gulp-filter"); const _filter = require("gulp-filter");
const rename = require("gulp-rename"); const rename = require("gulp-rename");
const _ = require("underscore");
const path = require("path"); const path = require("path");
const fs = require("fs"); const fs = require("fs");
const _rimraf = require("rimraf"); const _rimraf = require("rimraf");
@@ -100,22 +99,18 @@ function skipDirectories() {
}); });
} }
exports.skipDirectories = skipDirectories; exports.skipDirectories = skipDirectories;
function cleanNodeModule(name, excludes, includes) { function cleanNodeModules(rulePath) {
const toGlob = (path) => '**/node_modules/' + name + (path ? '/' + path : ''); const rules = fs.readFileSync(rulePath, 'utf8')
const negate = (str) => '!' + str; .split(/\r?\n/g)
const allFilter = _filter(toGlob('**'), { restore: true }); .map(line => line.trim())
const globs = [toGlob('**')].concat(excludes.map(_.compose(negate, toGlob))); .filter(line => line && !/^#/.test(line));
const excludes = rules.filter(line => !/^!/.test(line)).map(line => `!**/node_modules/${line}`);
const includes = rules.filter(line => /^!/.test(line)).map(line => `**/node_modules/${line.substr(1)}`);
const input = es.through(); const input = es.through();
const nodeModuleInput = input.pipe(allFilter); const output = es.merge(input.pipe(_filter(['**', ...excludes])), input.pipe(_filter(includes)));
let output = nodeModuleInput.pipe(_filter(globs));
if (includes) {
const includeGlobs = includes.map(toGlob);
output = es.merge(output, nodeModuleInput.pipe(_filter(includeGlobs)));
}
output = output.pipe(allFilter.restore);
return es.duplex(input, output); return es.duplex(input, output);
} }
exports.cleanNodeModule = cleanNodeModule; exports.cleanNodeModules = cleanNodeModules;
function loadSourcemaps() { function loadSourcemaps() {
const input = es.through(); const input = es.through();
const output = input const output = input

View File

@@ -132,23 +132,21 @@ export function skipDirectories(): NodeJS.ReadWriteStream {
}); });
} }
export function cleanNodeModule(name: string, excludes: string[], includes?: string[]): NodeJS.ReadWriteStream { export function cleanNodeModules(rulePath: string): NodeJS.ReadWriteStream {
const toGlob = (path: string) => '**/node_modules/' + name + (path ? '/' + path : ''); const rules = fs.readFileSync(rulePath, 'utf8')
const negate = (str: string) => '!' + str; .split(/\r?\n/g)
.map(line => line.trim())
.filter(line => line && !/^#/.test(line));
const allFilter = _filter(toGlob('**'), { restore: true }); const excludes = rules.filter(line => !/^!/.test(line)).map(line => `!**/node_modules/${line}`);
const globs = [toGlob('**')].concat(excludes.map(_.compose(negate, toGlob) as (x: string) => string)); const includes = rules.filter(line => /^!/.test(line)).map(line => `**/node_modules/${line.substr(1)}`);
const input = es.through(); const input = es.through();
const nodeModuleInput = input.pipe(allFilter); const output = es.merge(
let output: NodeJS.ReadWriteStream = nodeModuleInput.pipe(_filter(globs)); input.pipe(_filter(['**', ...excludes])),
input.pipe(_filter(includes))
);
if (includes) {
const includeGlobs = includes.map(toGlob);
output = es.merge(output, nodeModuleInput.pipe(_filter(includeGlobs)));
}
output = output.pipe(allFilter.restore);
return es.duplex(input, output); return es.duplex(input, output);
} }

View File

@@ -60,6 +60,18 @@ interface PreviewStyleLoadErrorMessage extends WebviewMessage {
}; };
} }
export class PreviewDocumentVersion {
public constructor(
public readonly resource: vscode.Uri,
public readonly version: number,
) { }
public equals(other: PreviewDocumentVersion): boolean {
return this.resource.fsPath === other.resource.fsPath
&& this.version === other.version;
}
}
export class MarkdownPreview extends Disposable { export class MarkdownPreview extends Disposable {
public static viewType = 'markdown.preview'; public static viewType = 'markdown.preview';
@@ -71,7 +83,7 @@ export class MarkdownPreview extends Disposable {
private throttleTimer: any; private throttleTimer: any;
private line: number | undefined = undefined; private line: number | undefined = undefined;
private firstUpdate = true; private firstUpdate = true;
private currentVersion?: { resource: vscode.Uri, version: number }; private currentVersion?: PreviewDocumentVersion;
private forceUpdate = false; private forceUpdate = false;
private isScrolling = false; private isScrolling = false;
private _disposed: boolean = false; private _disposed: boolean = false;
@@ -389,7 +401,8 @@ export class MarkdownPreview extends Disposable {
return; return;
} }
if (!this.forceUpdate && this.currentVersion && this.currentVersion.resource.fsPath === resource.fsPath && this.currentVersion.version === document.version) { const pendingVersion = new PreviewDocumentVersion(resource, document.version);
if (!this.forceUpdate && this.currentVersion && this.currentVersion.equals(pendingVersion)) {
if (this.line) { if (this.line) {
this.updateForView(resource, this.line); this.updateForView(resource, this.line);
} }
@@ -397,10 +410,14 @@ export class MarkdownPreview extends Disposable {
} }
this.forceUpdate = false; this.forceUpdate = false;
this.currentVersion = { resource, version: document.version }; this.currentVersion = pendingVersion;
if (this._resource === resource) { if (this._resource === resource) {
const content = await this._contentProvider.provideTextDocumentContent(document, this._previewConfigurations, this.line, this.state); const content = await this._contentProvider.provideTextDocumentContent(document, this._previewConfigurations, this.line, this.state);
this.setContent(content); // Another call to `doUpdate` may have happened.
// Make sure we are still updating for the correct document
if (this.currentVersion && this.currentVersion.equals(pendingVersion)) {
this.setContent(content);
}
} }
} }

View File

@@ -3,9 +3,9 @@
"version": "0.0.1", "version": "0.0.1",
"description": "Dependencies shared by all extensions", "description": "Dependencies shared by all extensions",
"dependencies": { "dependencies": {
"typescript": "3.4.5" "typescript": "3.5.0-dev.20190517"
}, },
"scripts": { "scripts": {
"postinstall": "node ./postinstall" "postinstall": "node ./postinstall"
} }
} }

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/PowerShell/EditorSyntax/commit/12b7d7257eb493e45a9af0af9094ec0c2a996712", "version": "https://github.com/PowerShell/EditorSyntax/commit/44eac8702f3cbe55a4ec70c1fdb163d42b4162fc",
"name": "PowerShell", "name": "PowerShell",
"scopeName": "source.powershell", "scopeName": "source.powershell",
"patterns": [ "patterns": [
@@ -252,7 +252,7 @@
] ]
}, },
"attribute": { "attribute": {
"begin": "(\\[)\\s*\\b(?i)(cmdletbinding|alias|outputtype|parameter|validatenotnull|validatenotnullorempty|validatecount|validateset|allownull|allowemptycollection|allowemptystring|validatescript|validaterange|validatepattern|validatelength)\\b", "begin": "(\\[)\\s*\\b(?i)(cmdletbinding|alias|outputtype|parameter|validatenotnull|validatenotnullorempty|validatecount|validateset|allownull|allowemptycollection|allowemptystring|validatescript|validaterange|validatepattern|validatelength|supportswildcards)\\b",
"beginCaptures": { "beginCaptures": {
"1": { "1": {
"name": "punctuation.section.bracket.begin.powershell" "name": "punctuation.section.bracket.begin.powershell"
@@ -283,33 +283,6 @@
} }
}, },
"patterns": [ "patterns": [
{
"include": "#variable"
},
{
"include": "#variableNoProperty"
},
{
"include": "#hashtable"
},
{
"include": "#scriptblock"
},
{
"include": "#doubleQuotedStringEscapes"
},
{
"include": "#doubleQuotedString"
},
{
"include": "#type"
},
{
"include": "#numericConstant"
},
{
"include": "#doubleQuotedString"
},
{ {
"include": "$self" "include": "$self"
}, },
@@ -323,17 +296,6 @@
"name": "keyword.operator.assignment.powershell" "name": "keyword.operator.assignment.powershell"
} }
} }
},
{
"begin": "(?<!')'",
"end": "'(?!')",
"name": "string.quoted.single.powershell",
"patterns": [
{
"match": "''",
"name": "constant.character.escape.powershell"
}
]
} }
] ]
} }
@@ -402,15 +364,31 @@
"doubleQuotedStringEscapes": { "doubleQuotedStringEscapes": {
"patterns": [ "patterns": [
{ {
"match": "`[0abnfrvt\"'$`]", "match": "`[`0abefnrtv\"'$]",
"name": "constant.character.escape.powershell" "name": "constant.character.escape.powershell"
}, },
{
"include": "#unicodeEscape"
},
{ {
"match": "\"\"", "match": "\"\"",
"name": "constant.character.escape.powershell" "name": "constant.character.escape.powershell"
} }
] ]
}, },
"unicodeEscape": {
"comment": "`u{xxxx} added in PowerShell 6.0",
"patterns": [
{
"match": "`u\\{(?:(?:10)?([0-9a-fA-F]){1,4}|0?\\g<1>{1,5})}",
"name": "constant.character.escape.powershell"
},
{
"match": "`u(?:\\{[0-9a-fA-F]{,6}.)?",
"name": "invalid.character.escape.powershell"
}
]
},
"function": { "function": {
"begin": "^(?:\\s*+)(?i)(function|filter|configuration|workflow)\\s+(?:(global|local|script|private):)?((?:\\p{L}|\\d|_|-|\\.)+)", "begin": "^(?:\\s*+)(?i)(function|filter|configuration|workflow)\\s+(?:(global|local|script|private):)?((?:\\p{L}|\\d|_|-|\\.)+)",
"beginCaptures": { "beginCaptures": {
@@ -644,6 +622,9 @@
}, },
{ {
"captures": { "captures": {
"0": {
"name": "support.variable.automatic.powershell"
},
"1": { "1": {
"name": "keyword.other.variable.definition.powershell" "name": "keyword.other.variable.definition.powershell"
}, },
@@ -655,7 +636,7 @@
} }
}, },
"comment": "Automatic variables are not constants, but they are read-only. In monokai (default) color schema support.variable doesn't have color, so we use constant.", "comment": "Automatic variables are not constants, but they are read-only. In monokai (default) color schema support.variable doesn't have color, so we use constant.",
"match": "(\\$)(?i:(\\$|\\^|\\?|_|Args|ConsoleFileName|Event|EventArgs|EventSubscriber|ForEach|Input|LastExitCode|Matches|MyInvocation|NestedPromptLevel|Profile|PSBoundParameters|PsCmdlet|PsCulture|PSDebugContext|PSItem|PSCommandPath|PSScriptRoot|PsUICulture|Pwd|Sender|SourceArgs|SourceEventArgs|StackTrace|Switch|This))((?:\\.(?:\\p{L}|\\d|_)+)*\\b)?\\b" "match": "(\\$)((?:[$^?])|(?i:_|Args|ConsoleFileName|Event|EventArgs|EventSubscriber|ForEach|Input|LastExitCode|Matches|MyInvocation|NestedPromptLevel|Profile|PSBoundParameters|PsCmdlet|PsCulture|PSDebugContext|PSItem|PSCommandPath|PSScriptRoot|PsUICulture|Pwd|Sender|SourceArgs|SourceEventArgs|StackTrace|Switch|This)\\b)((?:\\.(?:\\p{L}|\\d|_)+)*\\b)?"
}, },
{ {
"captures": { "captures": {
@@ -833,7 +814,7 @@
} }
}, },
"comment": "Automatic variables are not constants, but they are read-only...", "comment": "Automatic variables are not constants, but they are read-only...",
"match": "(\\$)(?i:(\\$|\\^|\\?|_|Args|ConsoleFileName|Event|EventArgs|EventSubscriber|ForEach|Input|LastExitCode|Matches|MyInvocation|NestedPromptLevel|Profile|PSBoundParameters|PsCmdlet|PsCulture|PSDebugContext|PSItem|PSCommandPath|PSScriptRoot|PsUICulture|Pwd|Sender|SourceArgs|SourceEventArgs|StackTrace|Switch|This))\\b" "match": "(\\$)((?:[$^?])|(?i:_|Args|ConsoleFileName|Event|EventArgs|EventSubscriber|ForEach|Input|LastExitCode|Matches|MyInvocation|NestedPromptLevel|Profile|PSBoundParameters|PsCmdlet|PsCulture|PSDebugContext|PSItem|PSCommandPath|PSScriptRoot|PsUICulture|Pwd|Sender|SourceArgs|SourceEventArgs|StackTrace|Switch|This)\\b)"
}, },
{ {
"captures": { "captures": {
@@ -865,7 +846,7 @@
"name": "entity.name.function.invocation.powershell" "name": "entity.name.function.invocation.powershell"
} }
}, },
"match": "(?i:(\\$|@)(global|local|private|script|using|workflow):((?:\\p{L}|\\d|_)+))" "match": "(?i:(\\$)(global|local|private|script|using|workflow):((?:\\p{L}|\\d|_)+))"
}, },
{ {
"captures": { "captures": {
@@ -981,9 +962,6 @@
{ {
"include": "#variableNoProperty" "include": "#variableNoProperty"
}, },
{
"include": "#variable"
},
{ {
"include": "#doubleQuotedStringEscapes" "include": "#doubleQuotedStringEscapes"
}, },

View File

@@ -694,24 +694,24 @@
}, },
{ {
"c": "$", "c": "$",
"t": "source.powershell meta.scriptblock.powershell meta.scriptblock.powershell keyword.other.variable.definition.powershell", "t": "source.powershell meta.scriptblock.powershell meta.scriptblock.powershell support.variable.automatic.powershell punctuation.definition.variable.powershell",
"r": { "r": {
"dark_plus": null, "dark_plus": "support.variable: #9CDCFE",
"light_plus": null, "light_plus": "support.variable: #001080",
"dark_vs": null, "dark_vs": "default: #D4D4D4",
"light_vs": null, "light_vs": "default: #000000",
"hc_black": "keyword: #569CD6" "hc_black": "support.variable: #9CDCFE"
} }
}, },
{ {
"c": "_", "c": "_",
"t": "source.powershell meta.scriptblock.powershell meta.scriptblock.powershell support.constant.automatic.powershell", "t": "source.powershell meta.scriptblock.powershell meta.scriptblock.powershell support.variable.automatic.powershell",
"r": { "r": {
"dark_plus": null, "dark_plus": "support.variable: #9CDCFE",
"light_plus": null, "light_plus": "support.variable: #001080",
"dark_vs": null, "dark_vs": "default: #D4D4D4",
"light_vs": null, "light_vs": "default: #000000",
"hc_black": "default: #FFFFFF" "hc_black": "support.variable: #9CDCFE"
} }
}, },
{ {
@@ -1068,24 +1068,24 @@
}, },
{ {
"c": "$", "c": "$",
"t": "source.powershell meta.scriptblock.powershell interpolated.simple.source.powershell keyword.other.variable.definition.powershell", "t": "source.powershell meta.scriptblock.powershell interpolated.simple.source.powershell support.variable.automatic.powershell punctuation.definition.variable.powershell",
"r": { "r": {
"dark_plus": null, "dark_plus": "support.variable: #9CDCFE",
"light_plus": null, "light_plus": "support.variable: #001080",
"dark_vs": null, "dark_vs": "default: #D4D4D4",
"light_vs": null, "light_vs": "default: #000000",
"hc_black": "keyword: #569CD6" "hc_black": "support.variable: #9CDCFE"
} }
}, },
{ {
"c": "_", "c": "_",
"t": "source.powershell meta.scriptblock.powershell interpolated.simple.source.powershell support.constant.automatic.powershell", "t": "source.powershell meta.scriptblock.powershell interpolated.simple.source.powershell support.variable.automatic.powershell",
"r": { "r": {
"dark_plus": null, "dark_plus": "support.variable: #9CDCFE",
"light_plus": null, "light_plus": "support.variable: #001080",
"dark_vs": null, "dark_vs": "default: #D4D4D4",
"light_vs": null, "light_vs": "default: #000000",
"hc_black": "default: #FFFFFF" "hc_black": "support.variable: #9CDCFE"
} }
}, },
{ {
@@ -1266,24 +1266,24 @@
}, },
{ {
"c": "$", "c": "$",
"t": "source.powershell meta.scriptblock.powershell meta.scriptblock.powershell interpolated.simple.source.powershell keyword.other.variable.definition.powershell", "t": "source.powershell meta.scriptblock.powershell meta.scriptblock.powershell interpolated.simple.source.powershell support.variable.automatic.powershell punctuation.definition.variable.powershell",
"r": { "r": {
"dark_plus": null, "dark_plus": "support.variable: #9CDCFE",
"light_plus": null, "light_plus": "support.variable: #001080",
"dark_vs": null, "dark_vs": "default: #D4D4D4",
"light_vs": null, "light_vs": "default: #000000",
"hc_black": "keyword: #569CD6" "hc_black": "support.variable: #9CDCFE"
} }
}, },
{ {
"c": "_", "c": "_",
"t": "source.powershell meta.scriptblock.powershell meta.scriptblock.powershell interpolated.simple.source.powershell support.constant.automatic.powershell", "t": "source.powershell meta.scriptblock.powershell meta.scriptblock.powershell interpolated.simple.source.powershell support.variable.automatic.powershell",
"r": { "r": {
"dark_plus": null, "dark_plus": "support.variable: #9CDCFE",
"light_plus": null, "light_plus": "support.variable: #001080",
"dark_vs": null, "dark_vs": "default: #D4D4D4",
"light_vs": null, "light_vs": "default: #000000",
"hc_black": "default: #FFFFFF" "hc_black": "support.variable: #9CDCFE"
} }
}, },
{ {
@@ -1431,24 +1431,24 @@
}, },
{ {
"c": "$", "c": "$",
"t": "source.powershell meta.scriptblock.powershell meta.scriptblock.powershell meta.scriptblock.powershell interpolated.simple.source.powershell keyword.other.variable.definition.powershell", "t": "source.powershell meta.scriptblock.powershell meta.scriptblock.powershell meta.scriptblock.powershell interpolated.simple.source.powershell support.variable.automatic.powershell punctuation.definition.variable.powershell",
"r": { "r": {
"dark_plus": null, "dark_plus": "support.variable: #9CDCFE",
"light_plus": null, "light_plus": "support.variable: #001080",
"dark_vs": null, "dark_vs": "default: #D4D4D4",
"light_vs": null, "light_vs": "default: #000000",
"hc_black": "keyword: #569CD6" "hc_black": "support.variable: #9CDCFE"
} }
}, },
{ {
"c": "matches", "c": "matches",
"t": "source.powershell meta.scriptblock.powershell meta.scriptblock.powershell meta.scriptblock.powershell interpolated.simple.source.powershell support.constant.automatic.powershell", "t": "source.powershell meta.scriptblock.powershell meta.scriptblock.powershell meta.scriptblock.powershell interpolated.simple.source.powershell support.variable.automatic.powershell",
"r": { "r": {
"dark_plus": null, "dark_plus": "support.variable: #9CDCFE",
"light_plus": null, "light_plus": "support.variable: #001080",
"dark_vs": null, "dark_vs": "default: #D4D4D4",
"light_vs": null, "light_vs": "default: #000000",
"hc_black": "default: #FFFFFF" "hc_black": "support.variable: #9CDCFE"
} }
}, },
{ {
@@ -1508,24 +1508,24 @@
}, },
{ {
"c": "$", "c": "$",
"t": "source.powershell meta.scriptblock.powershell meta.scriptblock.powershell meta.scriptblock.powershell interpolated.simple.source.powershell keyword.other.variable.definition.powershell", "t": "source.powershell meta.scriptblock.powershell meta.scriptblock.powershell meta.scriptblock.powershell interpolated.simple.source.powershell support.variable.automatic.powershell punctuation.definition.variable.powershell",
"r": { "r": {
"dark_plus": null, "dark_plus": "support.variable: #9CDCFE",
"light_plus": null, "light_plus": "support.variable: #001080",
"dark_vs": null, "dark_vs": "default: #D4D4D4",
"light_vs": null, "light_vs": "default: #000000",
"hc_black": "keyword: #569CD6" "hc_black": "support.variable: #9CDCFE"
} }
}, },
{ {
"c": "matches", "c": "matches",
"t": "source.powershell meta.scriptblock.powershell meta.scriptblock.powershell meta.scriptblock.powershell interpolated.simple.source.powershell support.constant.automatic.powershell", "t": "source.powershell meta.scriptblock.powershell meta.scriptblock.powershell meta.scriptblock.powershell interpolated.simple.source.powershell support.variable.automatic.powershell",
"r": { "r": {
"dark_plus": null, "dark_plus": "support.variable: #9CDCFE",
"light_plus": null, "light_plus": "support.variable: #001080",
"dark_vs": null, "dark_vs": "default: #D4D4D4",
"light_vs": null, "light_vs": "default: #000000",
"hc_black": "default: #FFFFFF" "hc_black": "support.variable: #9CDCFE"
} }
}, },
{ {

View File

@@ -8,8 +8,7 @@
"vscode": "*" "vscode": "*"
}, },
"scripts": { "scripts": {
"vscode:prepublish": "node ../../node_modules/gulp/bin/gulp.js --gulpfile ../../build/gulpfile.extensions.js compile-extension:vscode-colorize-tests ./tsconfig.json", "vscode:prepublish": "node ../../node_modules/gulp/bin/gulp.js --gulpfile ../../build/gulpfile.extensions.js compile-extension:vscode-colorize-tests ./tsconfig.json"
"postinstall": "node ./node_modules/vscode/bin/install"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^10.12.21", "@types/node": "^10.12.21",

View File

@@ -4,3 +4,4 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
/// <reference types='@types/node'/> /// <reference types='@types/node'/>
/// <reference path='../../../../src/vs/vscode.d.ts'/>

View File

@@ -2,7 +2,7 @@
# yarn lockfile v1 # yarn lockfile v1
typescript@3.4.5: typescript@3.5.0-dev.20190517:
version "3.4.5" version "3.5.0-dev.20190517"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.4.5.tgz#2d2618d10bb566572b8d7aad5180d84257d70a99" resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.5.0-dev.20190517.tgz#5a85f1091cf33fde39b04f898c5730e30edd3e39"
integrity sha512-YycBxUb49UUhdNMU5aJ7z5Ej2XGmaIBL0x34vZ82fn3hGvD+bgrMrVDpatgz2f7YxUMJxMkbWxJZeAvDxVe7Vw== integrity sha512-KoBHq6ytEApXKTDtmTu4Sp/tC5SPe4FpvwutLEANhwdMPblqZdh7APuH7I/ceMlgfHSa7B00JgF7NokUJQi0/g==

View File

@@ -25,7 +25,8 @@
"tslint": "node node_modules/tslint/bin/tslint -c tslint-gci.json -p src/tsconfig.json", "tslint": "node node_modules/tslint/bin/tslint -c tslint-gci.json -p src/tsconfig.json",
"strict-null-check": "tsc -p src/tsconfig.strictNullChecks.json", "strict-null-check": "tsc -p src/tsconfig.strictNullChecks.json",
"strict-null-check-watch": "tsc -p src/tsconfig.strictNullChecks.json --watch", "strict-null-check-watch": "tsc -p src/tsconfig.strictNullChecks.json --watch",
"strict-initialization-watch": "tsc --watch -p src/tsconfig.json --noEmit --strictPropertyInitialization" "strict-initialization-watch": "tsc --watch -p src/tsconfig.json --noEmit --strictPropertyInitialization",
"web": "node scripts/code-web.js"
}, },
"dependencies": { "dependencies": {
"@angular/animations": "~4.1.3", "@angular/animations": "~4.1.3",
@@ -75,7 +76,7 @@
"vscode-ripgrep": "^1.2.5", "vscode-ripgrep": "^1.2.5",
"vscode-sqlite3": "4.0.7", "vscode-sqlite3": "4.0.7",
"vscode-textmate": "^4.0.1", "vscode-textmate": "^4.0.1",
"vscode-xterm": "3.13.0-beta3", "vscode-xterm": "3.14.0-beta2",
"yauzl": "^2.9.1", "yauzl": "^2.9.1",
"yazl": "^2.4.3", "yazl": "^2.4.3",
"zone.js": "^0.8.4" "zone.js": "^0.8.4"
@@ -131,6 +132,7 @@
"gulp-uglify": "^3.0.0", "gulp-uglify": "^3.0.0",
"gulp-untar": "^0.0.7", "gulp-untar": "^0.0.7",
"gulp-vinyl-zip": "^2.1.2", "gulp-vinyl-zip": "^2.1.2",
"http-server": "^0.11.1",
"husky": "^0.13.1", "husky": "^0.13.1",
"innosetup-compiler": "^5.5.60", "innosetup-compiler": "^5.5.60",
"is": "^3.1.0", "is": "^3.1.0",
@@ -143,6 +145,7 @@
"mkdirp": "^0.5.0", "mkdirp": "^0.5.0",
"mocha": "^2.2.5", "mocha": "^2.2.5",
"mocha-junit-reporter": "^1.17.0", "mocha-junit-reporter": "^1.17.0",
"opn": "^5.4.0",
"optimist": "0.3.5", "optimist": "0.3.5",
"p-all": "^1.0.0", "p-all": "^1.0.0",
"pump": "^1.0.1", "pump": "^1.0.1",
@@ -155,7 +158,7 @@
"source-map": "^0.4.4", "source-map": "^0.4.4",
"temp-write": "^3.4.0", "temp-write": "^3.4.0",
"ts-loader": "^4.4.2", "ts-loader": "^4.4.2",
"tslint": "^5.11.0", "tslint": "^5.16.0",
"tslint-microsoft-contrib": "^6.0.0", "tslint-microsoft-contrib": "^6.0.0",
"typemoq": "^0.3.2", "typemoq": "^0.3.2",
"typescript": "3.4.5", "typescript": "3.4.5",

14
scripts/code-web.js Normal file
View File

@@ -0,0 +1,14 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
const httpServer = require('http-server');
const opn = require('opn');
const url = 'http://127.0.0.1:8080/out/vs/code/browser/workbench/workbench.html';
httpServer.createServer({ root: '.', cache: 5 }).listen(8080);
console.log(`Open ${url} in your browser`);
opn(url);

View File

@@ -12,7 +12,7 @@ exports.base = [{
}]; }];
exports.workbench = require('./vs/workbench/buildfile').collectModules(['vs/workbench/workbench.main']); exports.workbench = require('./vs/workbench/buildfile').collectModules(['vs/workbench/workbench.main']);
exports.workbenchNodeless = require('./vs/workbench/buildfile').collectModules(['vs/workbench/workbench.nodeless.main']); exports.workbenchWeb = require('./vs/workbench/buildfile').collectModules(['vs/workbench/workbench.web.main']);
exports.code = require('./vs/code/buildfile').collectModules(); exports.code = require('./vs/code/buildfile').collectModules();

View File

@@ -14,7 +14,7 @@
background: url('check.svg') center center no-repeat; background: url('check.svg') center center no-repeat;
} }
.vs-dark.monaco-shell .custom-checkbox.sql-checkbox.checked { .vs-dark .custom-checkbox.sql-checkbox.checked {
background: url('check_inverse.svg') center center no-repeat; background: url('check_inverse.svg') center center no-repeat;
} }

View File

@@ -7,8 +7,8 @@ import { IAction, IActionRunner, ActionRunner } from 'vs/base/common/actions';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { KeyCode, KeyMod } from 'vs/base/common/keyCodes'; import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
import { import {
IActionBarOptions, ActionsOrientation, IActionItem, IActionBarOptions, ActionsOrientation, IActionViewItem,
IActionOptions, ActionItem, BaseActionItem IActionOptions, ActionViewItem, BaseActionViewItem
} from 'vs/base/browser/ui/actionbar/actionbar'; } from 'vs/base/browser/ui/actionbar/actionbar';
import * as lifecycle from 'vs/base/common/lifecycle'; import * as lifecycle from 'vs/base/common/lifecycle';
import * as DOM from 'vs/base/browser/dom'; import * as DOM from 'vs/base/browser/dom';
@@ -31,7 +31,7 @@ export class ActionBar extends ActionRunner implements IActionRunner {
private _context: any; private _context: any;
// Items // Items
private _items: IActionItem[]; private _items: IActionViewItem[];
private _focusedItem?: number; private _focusedItem?: number;
private _focusTracker: DOM.IFocusTracker; private _focusTracker: DOM.IFocusTracker;
@@ -214,14 +214,14 @@ export class ActionBar extends ActionRunner implements IActionRunner {
actionItemElement.className = 'action-item'; actionItemElement.className = 'action-item';
actionItemElement.setAttribute('role', 'presentation'); actionItemElement.setAttribute('role', 'presentation');
let item: IActionItem | undefined = undefined; let item: IActionViewItem | undefined = undefined;
if (this._options.actionItemProvider) { if (this._options.actionViewItemProvider) {
item = this._options.actionItemProvider(action); item = this._options.actionViewItemProvider(action);
} }
if (!item) { if (!item) {
item = new ActionItem(this.context, action, options); item = new ActionViewItem(this.context, action, options);
} }
item.actionRunner = this._actionRunner; item.actionRunner = this._actionRunner;
@@ -248,7 +248,7 @@ export class ActionBar extends ActionRunner implements IActionRunner {
public clear(): void { public clear(): void {
// Do not dispose action items if they were provided from outside // Do not dispose action items if they were provided from outside
this._items = this._options.actionItemProvider ? [] : lifecycle.dispose(this._items); this._items = this._options.actionViewItemProvider ? [] : lifecycle.dispose(this._items);
DOM.clearNode(this._actionsList); DOM.clearNode(this._actionsList);
} }
@@ -274,7 +274,7 @@ export class ActionBar extends ActionRunner implements IActionRunner {
} }
let startIndex = this._focusedItem; let startIndex = this._focusedItem;
let item: IActionItem; let item: IActionViewItem;
do { do {
this._focusedItem = (this._focusedItem + 1) % this._items.length; this._focusedItem = (this._focusedItem + 1) % this._items.length;
@@ -294,7 +294,7 @@ export class ActionBar extends ActionRunner implements IActionRunner {
} }
let startIndex = this._focusedItem; let startIndex = this._focusedItem;
let item: IActionItem; let item: IActionViewItem;
do { do {
this._focusedItem = this._focusedItem - 1; this._focusedItem = this._focusedItem - 1;
@@ -343,7 +343,7 @@ export class ActionBar extends ActionRunner implements IActionRunner {
// trigger action // trigger action
let actionItem = this._items[this._focusedItem]; let actionItem = this._items[this._focusedItem];
if (actionItem instanceof BaseActionItem) { if (actionItem instanceof BaseActionViewItem) {
const context = (actionItem._context === null || actionItem._context === undefined) ? event : actionItem._context; const context = (actionItem._context === null || actionItem._context === undefined) ? event : actionItem._context;
this.run(actionItem._action, context); this.run(actionItem._action, context);
} }

View File

@@ -43,8 +43,8 @@ export class Taskbar {
this.actionBar = new ActionBar(element, { this.actionBar = new ActionBar(element, {
orientation: options.orientation, orientation: options.orientation,
ariaLabel: options.ariaLabel, ariaLabel: options.ariaLabel,
actionItemProvider: (action: Action) => { actionViewItemProvider: (action: Action) => {
return options.actionItemProvider ? options.actionItemProvider(action) : undefined; return options.actionViewItemProvider ? options.actionViewItemProvider(action) : undefined;
} }
}); });
} }

View File

@@ -397,7 +397,7 @@ export class MainThreadNotebookDocumentsAndEditors extends Disposable implements
let isUntitled: boolean = uri.scheme === Schemas.untitled; let isUntitled: boolean = uri.scheme === Schemas.untitled;
const fileInput = isUntitled ? this._untitledEditorService.createOrGet(uri, notebookModeId, options.initialContent) : const fileInput = isUntitled ? this._untitledEditorService.createOrGet(uri, notebookModeId, options.initialContent) :
this._editorService.createInput({ resource: uri, language: notebookModeId }); this._editorService.createInput({ resource: uri, mode: notebookModeId });
let input = this._instantiationService.createInstance(NotebookInput, path.basename(uri.fsPath), uri, fileInput); let input = this._instantiationService.createInstance(NotebookInput, path.basename(uri.fsPath), uri, fileInput);
input.defaultKernel = options.defaultKernel; input.defaultKernel = options.defaultKernel;
input.connectionProfile = new ConnectionProfile(this._capabilitiesService, options.connectionProfile); input.connectionProfile = new ConnectionProfile(this._capabilitiesService, options.connectionProfile);

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.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
.monaco-shell .modal { .modal {
background-color: rgba(204, 204, 204, 0.6); background-color: rgba(204, 204, 204, 0.6);
right: 0; right: 0;
left: 0; left: 0;
@@ -13,7 +13,7 @@
z-index: 500; z-index: 500;
} }
.monaco-shell .modal:not(.flyout-dialog) .modal-dialog { .modal:not(.flyout-dialog) .modal-dialog {
margin: auto; margin: auto;
width: 640px; width: 640px;
height: 480px; height: 480px;
@@ -32,7 +32,7 @@
height: 25px; height: 25px;
} }
.monaco-shell .modal.flyout-dialog .modal-dialog { .modal.flyout-dialog .modal-dialog {
margin: auto auto auto auto; margin: auto auto auto auto;
height: 100%; height: 100%;
width: 500px; width: 500px;
@@ -40,14 +40,13 @@
position: absolute; position: absolute;
overflow-y: hidden; overflow-y: hidden;
} }
.modal.flyout-dialog.wide .modal-dialog {
.monaco-shell .modal.flyout-dialog.wide .modal-dialog {
width: 1200px; width: 1200px;
max-width: 95%; max-width: 95%;
min-width: 400px; min-width: 400px;
} }
.monaco-shell .modal.flyout-dialog .modal-content { .modal.flyout-dialog .modal-content {
height: 100%; height: 100%;
font-size: 11px; font-size: 11px;
display: flex; display: flex;
@@ -66,10 +65,10 @@
margin-right: 10px; margin-right: 10px;
} }
.monaco-shell .modal.flyout-dialog .modal-body, .modal.flyout-dialog .modal-body,
.monaco-shell .modal.flyout-dialog .angular-modal-body, .modal.flyout-dialog .angular-modal-body,
/* Style for body and footer in modal dialog. This should be applied to dialog created with angular component. */ /* Style for body and footer in modal dialog. This should be applied to dialog created with angular component. */
.monaco-shell .modal.flyout-dialog .modal-body-and-footer { .modal.flyout-dialog .modal-body-and-footer {
flex: 1 1; flex: 1 1;
overflow: hidden; overflow: hidden;
} }
@@ -105,11 +104,11 @@
padding-left: 4px; padding-left: 4px;
} }
.vs-dark.monaco-shell .modal.flyout-dialog .input { .vs-dark .modal.flyout-dialog .input {
background-color: #3C3C3C; background-color: #3C3C3C;
} }
.vs-dark.monaco-shell .modal.flyout-dialog input:disabled { .vs-dark .modal.flyout-dialog input:disabled {
background-color: #E1E1E1; background-color: #E1E1E1;
color: #3C3C3C; color: #3C3C3C;
} }

View File

@@ -10,7 +10,6 @@ import { IAction, ActionRunner, Action } from 'vs/base/common/actions';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView'; import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { IMenuService, MenuId, MenuItemAction } from 'vs/platform/actions/common/actions'; import { IMenuService, MenuId, MenuItemAction } from 'vs/platform/actions/common/actions';
import { ContextAwareMenuItemActionItem, fillInActionBarActions, fillInContextMenuActions } from 'vs/platform/actions/browser/menuItemActionItem';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { TreeItemCollapsibleState, ITreeViewDataProvider, TreeViewItemHandleArg, ViewContainer, ITreeItemLabel } from 'vs/workbench/common/views'; import { TreeItemCollapsibleState, ITreeViewDataProvider, TreeViewItemHandleArg, ViewContainer, ITreeItemLabel } from 'vs/workbench/common/views';
import { FileIconThemableWorkbenchTree } from 'vs/workbench/browser/parts/views/viewsViewlet'; import { FileIconThemableWorkbenchTree } from 'vs/workbench/browser/parts/views/viewsViewlet';
@@ -22,7 +21,7 @@ import { ICommandService } from 'vs/platform/commands/common/commands';
import * as DOM from 'vs/base/browser/dom'; import * as DOM from 'vs/base/browser/dom';
import { IDataSource, ITree, IRenderer, ContextMenuEvent } from 'vs/base/parts/tree/browser/tree'; import { IDataSource, ITree, IRenderer, ContextMenuEvent } from 'vs/base/parts/tree/browser/tree';
import { ResourceLabel } from 'vs/workbench/browser/labels'; import { ResourceLabel } from 'vs/workbench/browser/labels';
import { ActionBar, IActionItemProvider, ActionItem } from 'vs/base/browser/ui/actionbar/actionbar'; import { ActionBar, IActionViewItemProvider, ActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import { basename } from 'vs/base/common/path'; import { basename } from 'vs/base/common/path';
import { LIGHT, FileThemeIcon, FolderThemeIcon, registerThemingParticipant } from 'vs/platform/theme/common/themeService'; import { LIGHT, FileThemeIcon, FolderThemeIcon, registerThemingParticipant } from 'vs/platform/theme/common/themeService';
@@ -46,6 +45,7 @@ import { ITreeItem, ITreeView } from 'sql/workbench/common/views';
import { IOEShimService } from 'sql/workbench/parts/objectExplorer/common/objectExplorerViewTreeShim'; import { IOEShimService } from 'sql/workbench/parts/objectExplorer/common/objectExplorerViewTreeShim';
import { equalsIgnoreCase } from 'vs/base/common/strings'; import { equalsIgnoreCase } from 'vs/base/common/strings';
import { NodeContextKey } from 'sql/workbench/parts/dataExplorer/common/nodeContext'; import { NodeContextKey } from 'sql/workbench/parts/dataExplorer/common/nodeContext';
import { fillInActionBarActions, fillInContextMenuActions, ContextAwareMenuEntryActionViewItem } from 'vs/platform/actions/browser/menuEntryActionViewItem';
class TitleMenus implements IDisposable { class TitleMenus implements IDisposable {
@@ -319,7 +319,7 @@ export class CustomTreeView extends Disposable implements ITreeView {
} }
private createTree() { private createTree() {
const actionItemProvider = (action: IAction) => action instanceof MenuItemAction ? this.instantiationService.createInstance(ContextAwareMenuItemActionItem, action) : undefined; const actionItemProvider = (action: IAction) => action instanceof MenuItemAction ? this.instantiationService.createInstance(ContextAwareMenuEntryActionViewItem, action) : undefined;
const menus = this.instantiationService.createInstance(TreeMenus, this.id); const menus = this.instantiationService.createInstance(TreeMenus, this.id);
const dataSource = this.instantiationService.createInstance(TreeDataSource, this, this.container, this.id); const dataSource = this.instantiationService.createInstance(TreeDataSource, this, this.container, this.id);
const renderer = this.instantiationService.createInstance(TreeRenderer, this.id, menus, actionItemProvider); const renderer = this.instantiationService.createInstance(TreeRenderer, this.id, menus, actionItemProvider);
@@ -599,7 +599,7 @@ class TreeRenderer implements IRenderer {
constructor( constructor(
private treeViewId: string, private treeViewId: string,
private menus: TreeMenus, private menus: TreeMenus,
private actionItemProvider: IActionItemProvider, private actionItemProvider: IActionViewItemProvider,
@IInstantiationService private instantiationService: IInstantiationService, @IInstantiationService private instantiationService: IInstantiationService,
@IWorkbenchThemeService private themeService: IWorkbenchThemeService, @IWorkbenchThemeService private themeService: IWorkbenchThemeService,
@IConfigurationService private configurationService: IConfigurationService, @IConfigurationService private configurationService: IConfigurationService,
@@ -623,7 +623,7 @@ class TreeRenderer implements IRenderer {
DOM.addClass(resourceLabel.element.element, 'custom-view-tree-node-item-resourceLabel'); DOM.addClass(resourceLabel.element.element, 'custom-view-tree-node-item-resourceLabel');
const actionsContainer = DOM.append(resourceLabel.element.element, DOM.$('.actions')); const actionsContainer = DOM.append(resourceLabel.element.element, DOM.$('.actions'));
const actionBar = new ActionBar(actionsContainer, { const actionBar = new ActionBar(actionsContainer, {
actionItemProvider: this.actionItemProvider, actionViewItemProvider: this.actionItemProvider,
actionRunner: new MultipleSelectionActionRunner(() => tree.getSelection()) actionRunner: new MultipleSelectionActionRunner(() => tree.getSelection())
}); });
@@ -769,10 +769,10 @@ class TreeController extends WorkbenchTreeController {
getActions: () => actions, getActions: () => actions,
getActionItem: (action) => { getActionViewItem: (action) => {
const keybinding = this._keybindingService.lookupKeybinding(action.id); const keybinding = this._keybindingService.lookupKeybinding(action.id);
if (keybinding) { if (keybinding) {
return new ActionItem(action, action, { label: true, keybinding: keybinding.getLabel() }); return new ActionViewItem(action, action, { label: true, keybinding: keybinding.getLabel() });
} }
return null; return null;
}, },

View File

@@ -181,7 +181,7 @@ function getNotebookFileExtensions(instantiationService: IInstantiationService):
function hasNotebookFileMode(input: EditorInput): boolean { function hasNotebookFileMode(input: EditorInput): boolean {
if (input instanceof UntitledEditorInput) { if (input instanceof UntitledEditorInput) {
let untitledCast: UntitledEditorInput = <UntitledEditorInput>input; let untitledCast: UntitledEditorInput = <UntitledEditorInput>input;
return (untitledCast && untitledCast.getModeId() === notebookModeId); return (untitledCast && untitledCast.getMode() === notebookModeId);
} }
return false; return false;
} }
@@ -200,7 +200,7 @@ function withService<TService, TResult>(instantiationService: IInstantiationServ
function hasSqlFileMode(input: EditorInput): boolean { function hasSqlFileMode(input: EditorInput): boolean {
if (input instanceof UntitledEditorInput) { if (input instanceof UntitledEditorInput) {
let untitledCast: UntitledEditorInput = <UntitledEditorInput>input; let untitledCast: UntitledEditorInput = <UntitledEditorInput>input;
return untitledCast && (untitledCast.getModeId() === undefined || untitledCast.getModeId() === sqlModeId); return untitledCast && (untitledCast.getMode() === undefined || untitledCast.getMode() === sqlModeId);
} }
return false; return false;

View File

@@ -94,7 +94,7 @@ export default class WebViewComponent extends ComponentBase implements IComponen
private setHtml(): void { private setHtml(): void {
if (this._webview && this.html) { if (this._webview && this.html) {
this._renderedHtml = this.html; this._renderedHtml = this.html;
this._webview.contents = this._renderedHtml; this._webview.html = this._renderedHtml;
this._webview.layout(); this._webview.layout();
} }
} }

View File

@@ -80,7 +80,7 @@ export class WebviewContent extends AngularDisposable implements OnInit, IDashbo
public setHtml(html: string): void { public setHtml(html: string): void {
this._html = html; this._html = html;
if (this._webview) { if (this._webview) {
this._webview.contents = html; this._webview.html = html;
this._webview.layout(); this._webview.layout();
} }
} }
@@ -112,7 +112,7 @@ export class WebviewContent extends AngularDisposable implements OnInit, IDashbo
this._onMessage.fire(e); this._onMessage.fire(e);
}); });
if (this._html) { if (this._html) {
this._webview.contents = this._html; this._webview.html = this._html;
} }
this._webview.layout(); this._webview.layout();
} }

View File

@@ -60,7 +60,7 @@ export class WebviewWidget extends DashboardWidget implements IDashboardWidget,
public setHtml(html: string): void { public setHtml(html: string): void {
this._html = html; this._html = html;
if (this._webview) { if (this._webview) {
this._webview.contents = html; this._webview.html = html;
this._webview.layout(); this._webview.layout();
} }
} }
@@ -110,7 +110,7 @@ export class WebviewWidget extends DashboardWidget implements IDashboardWidget,
this._onMessage.fire(e); this._onMessage.fire(e);
}); });
if (this._html) { if (this._html) {
this._webview.contents = this._html; this._webview.html = this._html;
} }
this._webview.layout(); this._webview.layout();
} }

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 { Action, IActionItem, IActionRunner } from 'vs/base/common/actions'; import { Action, IActionViewItem, IActionRunner } from 'vs/base/common/actions';
import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IQueryModelService } from 'sql/platform/query/common/queryModel'; import { IQueryModelService } from 'sql/platform/query/common/queryModel';
import { SelectBox } from 'sql/base/browser/ui/selectBox/selectBox'; import { SelectBox } from 'sql/base/browser/ui/selectBox/selectBox';
@@ -150,7 +150,7 @@ export class ChangeMaxRowsAction extends EditDataAction {
* Action item that handles the dropdown (combobox) that lists the avaliable number of row selections * Action item that handles the dropdown (combobox) that lists the avaliable number of row selections
* for an edit data session * for an edit data session
*/ */
export class ChangeMaxRowsActionItem implements IActionItem { export class ChangeMaxRowsActionItem implements IActionViewItem {
public actionRunner: IActionRunner; public actionRunner: IActionRunner;
public defaultRowCount: number; public defaultRowCount: number;

View File

@@ -19,7 +19,7 @@ import { EditDataInput } from 'sql/workbench/parts/editData/common/editDataInput
import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import * as queryContext from 'sql/workbench/parts/query/common/queryContext'; import * as queryContext from 'sql/workbench/parts/query/common/queryContext';
import { Taskbar, ITaskbarContent } from 'sql/base/browser/ui/taskbar/taskbar'; import { Taskbar, ITaskbarContent } from 'sql/base/browser/ui/taskbar/taskbar';
import { IActionItem } from 'vs/base/browser/ui/actionbar/actionbar'; import { IActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { Action } from 'vs/base/common/actions'; import { Action } from 'vs/base/common/actions';
import { IQueryModelService } from 'sql/platform/query/common/queryModel'; import { IQueryModelService } from 'sql/platform/query/common/queryModel';
import { IEditorDescriptorService } from 'sql/workbench/services/queryEditor/common/editorDescriptorService'; import { IEditorDescriptorService } from 'sql/workbench/services/queryEditor/common/editorDescriptorService';
@@ -313,7 +313,7 @@ export class EditDataEditor extends BaseEditor {
// Create QueryTaskbar // Create QueryTaskbar
this._taskbarContainer = DOM.append(parentElement, DOM.$('div')); this._taskbarContainer = DOM.append(parentElement, DOM.$('div'));
this._taskbar = new Taskbar(this._taskbarContainer, { this._taskbar = new Taskbar(this._taskbarContainer, {
actionItemProvider: (action: Action) => this._getChangeMaxRowsAction(action) actionViewItemProvider: (action: Action) => this._getChangeMaxRowsAction(action)
}); });
// Create Actions for the toolbar // Create Actions for the toolbar
@@ -344,7 +344,7 @@ export class EditDataEditor extends BaseEditor {
/** /**
* Gets the IActionItem for the list of row number drop down * Gets the IActionItem for the list of row number drop down
*/ */
private _getChangeMaxRowsAction(action: Action): IActionItem { private _getChangeMaxRowsAction(action: Action): IActionViewItem {
let actionID = ChangeMaxRowsAction.ID; let actionID = ChangeMaxRowsAction.ID;
if (action.id === actionID) { if (action.id === actionID) {
if (!this._changeMaxRowsActionItem) { if (!this._changeMaxRowsActionItem) {

View File

@@ -119,8 +119,8 @@ input#accordion:checked ~ .accordion-content {
padding-bottom: 10px; padding-bottom: 10px;
} }
.vs-dark.monaco-shell .all-jobs >.back-button-icon, .vs-dark .all-jobs >.back-button-icon,
.hc-black.monaco-shell .all-jobs >.back-button-icon { .hc-black .all-jobs >.back-button-icon {
content: url('back_inverse.svg'); content: url('back_inverse.svg');
} }

View File

@@ -14,10 +14,9 @@ import { IContextMenuService, IContextViewService } from 'vs/platform/contextvie
import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { attachSelectBoxStyler } from 'vs/platform/theme/common/styler'; import { attachSelectBoxStyler } from 'vs/platform/theme/common/styler';
import { MenuId, IMenuService, MenuItemAction } from 'vs/platform/actions/common/actions'; import { MenuId, IMenuService, MenuItemAction } from 'vs/platform/actions/common/actions';
import { IAction, Action, IActionItem } from 'vs/base/common/actions'; import { IAction, Action, IActionViewItem } from 'vs/base/common/actions';
import { IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey'; import { IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { fillInActions, LabeledMenuItemActionItem } from 'vs/platform/actions/browser/menuItemActionItem';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet'; import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { AngularDisposable } from 'sql/base/node/lifecycle'; import { AngularDisposable } from 'sql/base/node/lifecycle';
@@ -48,6 +47,7 @@ import { createErrorWithActions } from 'vs/base/common/errorsWithActions';
import { toErrorMessage } from 'vs/base/common/errorMessage'; import { toErrorMessage } from 'vs/base/common/errorMessage';
import { ILogService } from 'vs/platform/log/common/log'; import { ILogService } from 'vs/platform/log/common/log';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles'; import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { LabeledMenuItemActionItem, fillInActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
export const NOTEBOOK_SELECTOR: string = 'notebook-component'; export const NOTEBOOK_SELECTOR: string = 'notebook-component';
@@ -405,7 +405,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
this._trustedAction.enabled = false; this._trustedAction.enabled = false;
let taskbar = <HTMLElement>this.toolbar.nativeElement; let taskbar = <HTMLElement>this.toolbar.nativeElement;
this._actionBar = new Taskbar(taskbar, { actionItemProvider: action => this.actionItemProvider(action as Action) }); this._actionBar = new Taskbar(taskbar, { actionViewItemProvider: action => this.actionItemProvider(action as Action) });
this._actionBar.context = this; this._actionBar.context = this;
this._actionBar.setContent([ this._actionBar.setContent([
{ action: addCodeCellButton }, { action: addCodeCellButton },
@@ -419,7 +419,7 @@ export class NotebookComponent extends AngularDisposable implements OnInit, OnDe
} }
private actionItemProvider(action: Action): IActionItem { private actionItemProvider(action: Action): IActionViewItem {
// Check extensions to create ActionItem; otherwise, return undefined // Check extensions to create ActionItem; otherwise, return undefined
// This is similar behavior that exists in MenuItemActionItem // This is similar behavior that exists in MenuItemActionItem
if (action instanceof MenuItemAction) { if (action instanceof MenuItemAction) {

View File

@@ -8,7 +8,6 @@ import { ContributableActionProvider } from 'vs/workbench/browser/actions';
import { IAction } from 'vs/base/common/actions'; import { IAction } from 'vs/base/common/actions';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { fillInActions } from 'vs/platform/actions/browser/menuItemActionItem';
import { import {
DisconnectConnectionAction, AddServerAction, DisconnectConnectionAction, AddServerAction,
@@ -31,6 +30,7 @@ import { TreeNodeContextKey } from 'sql/workbench/parts/objectExplorer/common/tr
import { IQueryManagementService } from 'sql/platform/query/common/queryManagement'; import { IQueryManagementService } from 'sql/platform/query/common/queryManagement';
import { IScriptingService } from 'sql/platform/scripting/common/scriptingService'; import { IScriptingService } from 'sql/platform/scripting/common/scriptingService';
import { ServerInfoContextKey } from 'sql/workbench/parts/connection/common/serverInfoContextKey'; import { ServerInfoContextKey } from 'sql/workbench/parts/connection/common/serverInfoContextKey';
import { fillInActions } from 'vs/platform/actions/browser/menuEntryActionViewItem';
/** /**
* Provides actions for the server tree elements * Provides actions for the server tree elements

View File

@@ -5,7 +5,7 @@
import 'vs/css!./media/queryActions'; import 'vs/css!./media/queryActions';
import * as nls from 'vs/nls'; import * as nls from 'vs/nls';
import { Action, IActionItem, IActionRunner } from 'vs/base/common/actions'; import { Action, IActionViewItem, IActionRunner } from 'vs/base/common/actions';
import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IContextViewService } from 'vs/platform/contextview/browser/contextView'; import { IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
@@ -427,7 +427,7 @@ export class ListDatabasesAction extends QueryTaskbarAction {
* Action item that handles the dropdown (combobox) that lists the available databases. * Action item that handles the dropdown (combobox) that lists the available databases.
* Based off StartDebugActionItem. * Based off StartDebugActionItem.
*/ */
export class ListDatabasesActionItem implements IActionItem { export class ListDatabasesActionItem implements IActionViewItem {
public static ID = 'listDatabaseQueryActionItem'; public static ID = 'listDatabaseQueryActionItem';
public actionRunner: IActionRunner; public actionRunner: IActionRunner;

View File

@@ -23,7 +23,7 @@ import { TextResourceEditor } from 'vs/workbench/browser/parts/editor/textResour
import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey'; import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IActionItem } from 'vs/base/browser/ui/actionbar/actionbar'; import { IActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { Action } from 'vs/base/common/actions'; import { Action } from 'vs/base/common/actions';
import { ISelectionData } from 'azdata'; import { ISelectionData } from 'azdata';
import { IDisposable } from 'vs/base/common/lifecycle'; import { IDisposable } from 'vs/base/common/lifecycle';
@@ -463,7 +463,7 @@ export class QueryEditor extends BaseEditor {
// Create QueryTaskbar // Create QueryTaskbar
this._taskbarContainer = DOM.append(parentElement, DOM.$('div')); this._taskbarContainer = DOM.append(parentElement, DOM.$('div'));
this._taskbar = new Taskbar(this._taskbarContainer, { this._taskbar = new Taskbar(this._taskbarContainer, {
actionItemProvider: (action: Action) => this._getActionItemForAction(action), actionViewItemProvider: (action: Action) => this._getActionItemForAction(action),
}); });
// Create Actions for the toolbar // Create Actions for the toolbar
@@ -513,7 +513,7 @@ export class QueryEditor extends BaseEditor {
* Gets the IActionItem for the List Databases dropdown if provided the associated Action. * Gets the IActionItem for the List Databases dropdown if provided the associated Action.
* Otherwise returns null. * Otherwise returns null.
*/ */
private _getActionItemForAction(action: Action): IActionItem { private _getActionItemForAction(action: Action): IActionViewItem {
if (action.id === ListDatabasesAction.ID) { if (action.id === ListDatabasesAction.ID) {
return this.listDatabasesActionItem; return this.listDatabasesActionItem;
} }

View File

@@ -146,8 +146,11 @@ export class QueryInput extends EditorInput implements IEncodingSupport, IConnec
// Description is shown beside the tab name in the combobox of open editors // Description is shown beside the tab name in the combobox of open editors
public getDescription(): string { return this._description; } public getDescription(): string { return this._description; }
public supportsSplitEditor(): boolean { return false; } public supportsSplitEditor(): boolean { return false; }
public getModeId(): string { return QueryInput.SCHEMA; } public getMode(): string { return QueryInput.SCHEMA; }
public revert(): Promise<boolean> { return this._sql.revert(); } public revert(): Promise<boolean> { return this._sql.revert(); }
public setMode(mode: string) {
this._sql.setMode(mode);
}
public matches(otherInput: any): boolean { public matches(otherInput: any): boolean {
if (otherInput instanceof QueryInput) { if (otherInput instanceof QueryInput) {

View File

@@ -121,7 +121,7 @@ export class WebViewDialog extends Modal {
} }
private updateDialogBody(): void { private updateDialogBody(): void {
this._webview.contents = this.html; this._webview.html = this.html;
} }
/* espace key */ /* espace key */

View File

@@ -303,7 +303,7 @@ export class QueryEditorService implements IQueryEditorService {
newEditorInput = queryInput; newEditorInput = queryInput;
} else { } else {
let uriCopy: URI = URI.from({ scheme: uri.scheme, authority: uri.authority, path: uri.path, query: uri.query, fragment: uri.fragment }); let uriCopy: URI = URI.from({ scheme: uri.scheme, authority: uri.authority, path: uri.path, query: uri.query, fragment: uri.fragment });
newEditorInput = QueryEditorService.instantiationService.createInstance(FileEditorInput, uriCopy, undefined); newEditorInput = QueryEditorService.instantiationService.createInstance(FileEditorInput, uriCopy, undefined, undefined);
} }
return newEditorInput; return newEditorInput;

View File

@@ -101,17 +101,6 @@ declare module 'vscode-xterm' {
*/ */
experimentalCharAtlas?: 'none' | 'static' | 'dynamic'; experimentalCharAtlas?: 'none' | 'static' | 'dynamic';
/**
* (EXPERIMENTAL) Defines which implementation to use for buffer lines.
*
* - 'JsArray': The default/stable implementation.
* - 'TypedArray': The new experimental implementation based on TypedArrays that is expected to
* significantly boost performance and memory consumption. Use at your own risk.
*
* @deprecated This option will be removed in the future.
*/
experimentalBufferLineImpl?: 'JsArray' | 'TypedArray';
/** /**
* The font size used to render text. * The font size used to render text.
*/ */
@@ -199,6 +188,18 @@ declare module 'vscode-xterm' {
* The color theme of the terminal. * The color theme of the terminal.
*/ */
theme?: ITheme; theme?: ITheme;
/**
* Whether "Windows mode" is enabled. Because Windows backends winpty and
* conpty operate by doing line wrapping on their side, xterm.js does not
* have access to wrapped lines. When Windows mode is enabled the following
* changes will be in effect:
*
* - Reflow is disabled.
* - Lines are assumed to be wrapped if the last character of the line is
* not whitespace.
*/
windowsMode?: boolean;
} }
/** /**
@@ -274,7 +275,7 @@ declare module 'vscode-xterm' {
* A callback that fires when the mouse leaves a link. Note that this can * A callback that fires when the mouse leaves a link. Note that this can
* happen even when tooltipCallback hasn't fired for the link yet. * happen even when tooltipCallback hasn't fired for the link yet.
*/ */
leaveCallback?: (event: MouseEvent, uri: string) => boolean | void; leaveCallback?: () => void;
/** /**
* The priority of the link matcher, this defines the order in which the link * The priority of the link matcher, this defines the order in which the link
@@ -306,6 +307,14 @@ declare module 'vscode-xterm' {
dispose(): void; dispose(): void;
} }
/**
* An event that can be listened to.
* @returns an `IDisposable` to stop listening.
*/
export interface IEvent<T> {
(listener: (e: T) => any): IDisposable;
}
export interface IMarker extends IDisposable { export interface IMarker extends IDisposable {
readonly id: number; readonly id: number;
readonly isDisposed: boolean; readonly isDisposed: boolean;
@@ -325,28 +334,39 @@ declare module 'vscode-xterm' {
/** /**
* The element containing the terminal. * The element containing the terminal.
*/ */
element: HTMLElement; readonly element: HTMLElement;
/** /**
* The textarea that accepts input for the terminal. * The textarea that accepts input for the terminal.
*/ */
textarea: HTMLTextAreaElement; readonly textarea: HTMLTextAreaElement;
/** /**
* The number of rows in the terminal's viewport. * The number of rows in the terminal's viewport. Use
* `ITerminalOptions.rows` to set this in the constructor and
* `Terminal.resize` for when the terminal exists.
*/ */
rows: number; readonly rows: number;
/** /**
* The number of columns in the terminal's viewport. * The number of columns in the terminal's viewport. Use
* `ITerminalOptions.cols` to set this in the constructor and
* `Terminal.resize` for when the terminal exists.
*/ */
cols: number; readonly cols: number;
/**
* (EXPERIMENTAL) The terminal's current buffer, this might be either the
* normal buffer or the alt buffer depending on what's running in the
* terminal.
*/
readonly buffer: IBuffer;
/** /**
* (EXPERIMENTAL) Get all markers registered against the buffer. If the alt * (EXPERIMENTAL) Get all markers registered against the buffer. If the alt
* buffer is active this will always return []. * buffer is active this will always return [].
*/ */
markers: IMarker[]; readonly markers: ReadonlyArray<IMarker>;
/** /**
* Natural language strings that can be localized. * Natural language strings that can be localized.
@@ -360,6 +380,70 @@ declare module 'vscode-xterm' {
*/ */
constructor(options?: ITerminalOptions); constructor(options?: ITerminalOptions);
/**
* Adds an event listener for the cursor moves.
* @returns an `IDisposable` to stop listening.
*/
onCursorMove: IEvent<void>;
/**
* Adds an event listener for when a data event fires. This happens for
* example when the user types or pastes into the terminal. The event value
* is whatever `string` results, in a typical setup, this should be passed
* on to the backing pty.
* @returns an `IDisposable` to stop listening.
*/
onData: IEvent<string>;
/**
* Adds an event listener for a key is pressed. The event value contains the
* string that will be sent in the data event as well as the DOM event that
* triggered it.
* @returns an `IDisposable` to stop listening.
*/
onKey: IEvent<{ key: string, domEvent: KeyboardEvent }>;
/**
* Adds an event listener for when a line feed is added.
* @returns an `IDisposable` to stop listening.
*/
onLineFeed: IEvent<void>;
/**
* Adds an event listener for when a scroll occurs. The event value is the
* new position of the viewport.
* @returns an `IDisposable` to stop listening.
*/
onScroll: IEvent<number>;
/**
* Adds an event listener for when a selection change occurs.
* @returns an `IDisposable` to stop listening.
*/
onSelectionChange: IEvent<void>;
/**
* Adds an event listener for when rows are rendered. The event value
* contains the start row and end rows of the rendered area (ranges from `0`
* to `Terminal.rows - 1`).
* @returns an `IDisposable` to stop listening.
*/
onRender: IEvent<{ start: number, end: number }>;
/**
* Adds an event listener for when the terminal is resized. The event value
* contains the new size.
* @returns an `IDisposable` to stop listening.
*/
onResize: IEvent<{ cols: number, rows: number }>;
/**
* Adds an event listener for when an OSC 0 or OSC 2 title change occurs.
* The event value is the new title.
* @returns an `IDisposable` to stop listening.
*/
onTitleChange: IEvent<string>;
/** /**
* Unfocus the terminal. * Unfocus the terminal.
*/ */
@@ -374,54 +458,63 @@ declare module 'vscode-xterm' {
* Registers an event listener. * Registers an event listener.
* @param type The type of the event. * @param type The type of the event.
* @param listener The listener. * @param listener The listener.
* @deprecated use `Terminal.onEvent(listener)` instead.
*/ */
on(type: 'blur' | 'focus' | 'linefeed' | 'selection', listener: () => void): void; on(type: 'blur' | 'focus' | 'linefeed' | 'selection', listener: () => void): void;
/** /**
* Registers an event listener. * Registers an event listener.
* @param type The type of the event. * @param type The type of the event.
* @param listener The listener. * @param listener The listener.
* @deprecated use `Terminal.onEvent(listener)` instead.
*/ */
on(type: 'data', listener: (...args: any[]) => void): void; on(type: 'data', listener: (...args: any[]) => void): void;
/** /**
* Registers an event listener. * Registers an event listener.
* @param type The type of the event. * @param type The type of the event.
* @param listener The listener. * @param listener The listener.
* @deprecated use `Terminal.onEvent(listener)` instead.
*/ */
on(type: 'key', listener: (key: string, event: KeyboardEvent) => void): void; on(type: 'key', listener: (key: string, event: KeyboardEvent) => void): void;
/** /**
* Registers an event listener. * Registers an event listener.
* @param type The type of the event. * @param type The type of the event.
* @param listener The listener. * @param listener The listener.
* @deprecated use `Terminal.onEvent(listener)` instead.
*/ */
on(type: 'keypress' | 'keydown', listener: (event: KeyboardEvent) => void): void; on(type: 'keypress' | 'keydown', listener: (event: KeyboardEvent) => void): void;
/** /**
* Registers an event listener. * Registers an event listener.
* @param type The type of the event. * @param type The type of the event.
* @param listener The listener. * @param listener The listener.
* @deprecated use `Terminal.onEvent(listener)` instead.
*/ */
on(type: 'refresh', listener: (data: { start: number, end: number }) => void): void; on(type: 'refresh', listener: (data: { start: number, end: number }) => void): void;
/** /**
* Registers an event listener. * Registers an event listener.
* @param type The type of the event. * @param type The type of the event.
* @param listener The listener. * @param listener The listener.
* @deprecated use `Terminal.onEvent(listener)` instead.
*/ */
on(type: 'resize', listener: (data: { cols: number, rows: number }) => void): void; on(type: 'resize', listener: (data: { cols: number, rows: number }) => void): void;
/** /**
* Registers an event listener. * Registers an event listener.
* @param type The type of the event. * @param type The type of the event.
* @param listener The listener. * @param listener The listener.
* @deprecated use `Terminal.onEvent(listener)` instead.
*/ */
on(type: 'scroll', listener: (ydisp: number) => void): void; on(type: 'scroll', listener: (ydisp: number) => void): void;
/** /**
* Registers an event listener. * Registers an event listener.
* @param type The type of the event. * @param type The type of the event.
* @param listener The listener. * @param listener The listener.
* @deprecated use `Terminal.onEvent(listener)` instead.
*/ */
on(type: 'title', listener: (title: string) => void): void; on(type: 'title', listener: (title: string) => void): void;
/** /**
* Registers an event listener. * Registers an event listener.
* @param type The type of the event. * @param type The type of the event.
* @param listener The listener. * @param listener The listener.
* @deprecated use `Terminal.onEvent(listener)` instead.
*/ */
on(type: string, listener: (...args: any[]) => void): void; on(type: string, listener: (...args: any[]) => void): void;
@@ -429,6 +522,7 @@ declare module 'vscode-xterm' {
* Deregisters an event listener. * Deregisters an event listener.
* @param type The type of the event. * @param type The type of the event.
* @param listener The listener. * @param listener The listener.
* @deprecated use `Terminal.onEvent(listener).dispose()` instead.
*/ */
off(type: 'blur' | 'focus' | 'linefeed' | 'selection' | 'data' | 'key' | 'keypress' | 'keydown' | 'refresh' | 'resize' | 'scroll' | 'title' | string, listener: (...args: any[]) => void): void; off(type: 'blur' | 'focus' | 'linefeed' | 'selection' | 'data' | 'key' | 'keypress' | 'keydown' | 'refresh' | 'resize' | 'scroll' | 'title' | string, listener: (...args: any[]) => void): void;
@@ -446,22 +540,19 @@ declare module 'vscode-xterm' {
* be used to conveniently remove the event listener. * be used to conveniently remove the event listener.
* @param type The type of event. * @param type The type of event.
* @param handler The event handler. * @param handler The event handler.
* @deprecated use `Terminal.onEvent(listener)` instead.
*/ */
addDisposableListener(type: string, handler: (...args: any[]) => void): IDisposable; addDisposableListener(type: string, handler: (...args: any[]) => void): IDisposable;
/** /**
* Resizes the terminal. * Resizes the terminal. It's best practice to debounce calls to resize,
* this will help ensure that the pty can respond to the resize event
* before another one occurs.
* @param x The number of columns to resize to. * @param x The number of columns to resize to.
* @param y The number of rows to resize to. * @param y The number of rows to resize to.
*/ */
resize(columns: number, rows: number): void; resize(columns: number, rows: number): void;
/**
* Writes text to the terminal, followed by a break line character (\n).
* @param data The text to write to the terminal.
*/
writeln(data: string): void;
/** /**
* Opens the terminal within an element. * Opens the terminal within an element.
* @param parent The element to create the terminal within. This element * @param parent The element to create the terminal within. This element
@@ -476,11 +567,35 @@ declare module 'vscode-xterm' {
* should be processed by the terminal and what keys should not. * should be processed by the terminal and what keys should not.
* @param customKeyEventHandler The custom KeyboardEvent handler to attach. * @param customKeyEventHandler The custom KeyboardEvent handler to attach.
* This is a function that takes a KeyboardEvent, allowing consumers to stop * This is a function that takes a KeyboardEvent, allowing consumers to stop
* propogation and/or prevent the default action. The function returns * propagation and/or prevent the default action. The function returns
* whether the event should be processed by xterm.js. * whether the event should be processed by xterm.js.
*/ */
attachCustomKeyEventHandler(customKeyEventHandler: (event: KeyboardEvent) => boolean): void; attachCustomKeyEventHandler(customKeyEventHandler: (event: KeyboardEvent) => boolean): void;
/**
* (EXPERIMENTAL) Adds a handler for CSI escape sequences.
* @param flag The flag should be one-character string, which specifies the
* final character (e.g "m" for SGR) of the CSI sequence.
* @param callback The function to handle the escape sequence. The callback
* is called with the numerical params, as well as the special characters
* (e.g. "$" for DECSCPP). Return true if the sequence was handled; false if
* we should try a previous handler (set by addCsiHandler or setCsiHandler).
* The most recently-added handler is tried first.
* @return An IDisposable you can call to remove this handler.
*/
addCsiHandler(flag: string, callback: (params: number[], collect: string) => boolean): IDisposable;
/**
* (EXPERIMENTAL) Adds a handler for OSC escape sequences.
* @param ident The number (first parameter) of the sequence.
* @param callback The function to handle the escape sequence. The callback
* is called with OSC data string. Return true if the sequence was handled;
* false if we should try a previous handler (set by addOscHandler or
* setOscHandler). The most recently-added handler is tried first.
* @return An IDisposable you can call to remove this handler.
*/
addOscHandler(ident: number, callback: (data: string) => boolean): IDisposable;
/** /**
* (EXPERIMENTAL) Registers a link matcher, allowing custom link patterns to * (EXPERIMENTAL) Registers a link matcher, allowing custom link patterns to
* be matched and handled. * be matched and handled.
@@ -555,11 +670,24 @@ declare module 'vscode-xterm' {
*/ */
getSelection(): string; getSelection(): string;
/**
* Gets the selection position or undefined if there is no selection.
*/
getSelectionPosition(): ISelectionPosition | undefined;
/** /**
* Clears the current terminal selection. * Clears the current terminal selection.
*/ */
clearSelection(): void; clearSelection(): void;
/**
* Selects text within the terminal.
* @param column The column the selection starts at..
* @param row The row the selection starts at.
* @param length The length of the selection.
*/
select(column: number, row: number, length: number): void;
/** /**
* Selects all text within the terminal. * Selects all text within the terminal.
*/ */
@@ -624,6 +752,20 @@ declare module 'vscode-xterm' {
*/ */
write(data: string): void; write(data: string): void;
/**
* Writes text to the terminal, followed by a break line character (\n).
* @param data The text to write to the terminal.
*/
writeln(data: string): void;
/**
* Writes UTF8 data to the terminal.
* This has a slight performance advantage over the string based write method
* due to lesser data conversions needed on the way from the pty to xterm.js.
* @param data The data to write to the terminal.
*/
writeUtf8(data: Uint8Array): void;
/** /**
* Retrieves an option's value from the terminal. * Retrieves an option's value from the terminal.
* @param key The option key. * @param key The option key.
@@ -633,7 +775,7 @@ declare module 'vscode-xterm' {
* Retrieves an option's value from the terminal. * Retrieves an option's value from the terminal.
* @param key The option key. * @param key The option key.
*/ */
getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'debug' | 'disableStdin' | 'enableBold' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'screenKeys' | 'useFlowControl' | 'visualBell'): boolean; getOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'debug' | 'disableStdin' | 'enableBold' | 'macOptionIsMeta' | 'rightClickSelectsWord' | 'popOnBell' | 'screenKeys' | 'useFlowControl' | 'visualBell' | 'windowsMode'): boolean;
/** /**
* Retrieves an option's value from the terminal. * Retrieves an option's value from the terminal.
* @param key The option key. * @param key The option key.
@@ -684,7 +826,7 @@ declare module 'vscode-xterm' {
* @param key The option key. * @param key The option key.
* @param value The option value. * @param value The option value.
*/ */
setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'debug' | 'disableStdin' | 'enableBold' | 'macOptionIsMeta' | 'popOnBell' | 'rightClickSelectsWord' | 'screenKeys' | 'useFlowControl' | 'visualBell', value: boolean): void; setOption(key: 'allowTransparency' | 'cancelEvents' | 'convertEol' | 'cursorBlink' | 'debug' | 'disableStdin' | 'enableBold' | 'macOptionIsMeta' | 'popOnBell' | 'rightClickSelectsWord' | 'screenKeys' | 'useFlowControl' | 'visualBell' | 'windowsMode', value: boolean): void;
/** /**
* Sets an option on the terminal. * Sets an option on the terminal.
* @param key The option key. * @param key The option key.
@@ -739,8 +881,134 @@ declare module 'vscode-xterm' {
* Applies an addon to the Terminal prototype, making it available to all * Applies an addon to the Terminal prototype, making it available to all
* newly created Terminals. * newly created Terminals.
* @param addon The addon to apply. * @param addon The addon to apply.
* @deprecated Use the new loadAddon API/addon format.
*/ */
static applyAddon(addon: any): void; static applyAddon(addon: any): void;
/**
* (EXPERIMENTAL) Loads an addon into this instance of xterm.js.
* @param addon The addon to load.
*/
loadAddon(addon: ITerminalAddon): void;
}
/**
* An addon that can provide additional functionality to the terminal.
*/
export interface ITerminalAddon extends IDisposable {
/**
* (EXPERIMENTAL) This is called when the addon is activated within xterm.js.
*/
activate(terminal: Terminal): void;
}
/**
* An object representing a selecrtion within the terminal.
*/
interface ISelectionPosition {
/**
* The start column of the selection.
*/
startColumn: number;
/**
* The start row of the selection.
*/
startRow: number;
/**
* The end column of the selection.
*/
endColumn: number;
/**
* The end row of the selection.
*/
endRow: number;
}
interface IBuffer {
/**
* The y position of the cursor. This ranges between `0` (when the
* cursor is at baseY) and `Terminal.rows - 1` (when the cursor is on the
* last row).
*/
readonly cursorY: number;
/**
* The x position of the cursor. This ranges between `0` (left side) and
* `Terminal.cols - 1` (right side).
*/
readonly cursorX: number;
/**
* The line within the buffer where the top of the viewport is.
*/
readonly viewportY: number;
/**
* The line within the buffer where the top of the bottom page is (when
* fully scrolled down);
*/
readonly baseY: number;
/**
* The amount of lines in the buffer.
*/
readonly length: number;
/**
* Gets a line from the buffer, or undefined if the line index does not exist.
*
* Note that the result of this function should be used immediately after calling as when the
* terminal updates it could lead to unexpected behavior.
*
* @param y The line index to get.
*/
getLine(y: number): IBufferLine | undefined;
}
interface IBufferLine {
/**
* Whether the line is wrapped from the previous line.
*/
readonly isWrapped: boolean;
/**
* Gets a cell from the line, or undefined if the line index does not exist.
*
* Note that the result of this function should be used immediately after calling as when the
* terminal updates it could lead to unexpected behavior.
*
* @param x The character index to get.
*/
getCell(x: number): IBufferCell;
/**
* Gets the line as a string. Note that this is gets only the string for the line, not taking
* isWrapped into account.
*
* @param trimRight Whether to trim any whitespace at the right of the line.
* @param startColumn The column to start from (inclusive).
* @param endColumn The column to end at (exclusive).
*/
translateToString(trimRight?: boolean, startColumn?: number, endColumn?: number): string;
}
interface IBufferCell {
/**
* The character within the cell.
*/
readonly char: string;
/**
* The width of the character. Some examples:
*
* - This is `1` for most cells.
* - This is `2` for wide character like CJK glyphs.
* - This is `0` for cells immediately following cells with a width of `2`.
*/
readonly width: number;
} }
} }
@@ -750,22 +1018,10 @@ declare module 'vscode-xterm' {
interface TerminalCore { interface TerminalCore {
debug: boolean; debug: boolean;
buffer: {
y: number;
ybase: number;
ydisp: number;
x: number;
lines: any[];
translateBufferLineToString(lineIndex: number, trimRight: boolean): string;
};
handler(text: string): void; handler(text: string): void;
/** _onScroll: IEventEmitter2<number>;
* Emit an event on the terminal. _onKey: IEventEmitter2<{ key: string }>;
*/
emit(type: string, data: any): void;
charMeasure?: { height: number, width: number }; charMeasure?: { height: number, width: number };
@@ -775,6 +1031,10 @@ declare module 'vscode-xterm' {
}; };
} }
interface IEventEmitter2<T> {
fire(e: T): void;
}
interface ISearchOptions { interface ISearchOptions {
/** /**
* Whether the find should be done as a regex. * Whether the find should be done as a regex.
@@ -794,7 +1054,6 @@ declare module 'vscode-xterm' {
_core: TerminalCore; _core: TerminalCore;
webLinksInit(handler?: (event: MouseEvent, uri: string) => void, options?: ILinkMatcherOptions): void; webLinksInit(handler?: (event: MouseEvent, uri: string) => void, options?: ILinkMatcherOptions): void;
winptyCompatInit(): void;
/** /**
* Find the next instance of the term, then scroll to and select it. If it * Find the next instance of the term, then scroll to and select it. If it

View File

@@ -45,13 +45,13 @@ class WindowManager {
// --- Pixel Ratio // --- Pixel Ratio
public getPixelRatio(): number { public getPixelRatio(): number {
let ctx = document.createElement('canvas').getContext('2d'); let ctx: any = document.createElement('canvas').getContext('2d');
let dpr = window.devicePixelRatio || 1; let dpr = window.devicePixelRatio || 1;
let bsr = (<any>ctx).webkitBackingStorePixelRatio || let bsr = ctx.webkitBackingStorePixelRatio ||
(<any>ctx).mozBackingStorePixelRatio || ctx.mozBackingStorePixelRatio ||
(<any>ctx).msBackingStorePixelRatio || ctx.msBackingStorePixelRatio ||
(<any>ctx).oBackingStorePixelRatio || ctx.oBackingStorePixelRatio ||
(<any>ctx).backingStorePixelRatio || 1; ctx.backingStorePixelRatio || 1;
return dpr / bsr; return dpr / bsr;
} }

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { IAction, IActionRunner } from 'vs/base/common/actions'; import { IAction, IActionRunner } from 'vs/base/common/actions';
import { IActionItem } from 'vs/base/browser/ui/actionbar/actionbar'; import { IActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { ResolvedKeybinding } from 'vs/base/common/keyCodes'; import { ResolvedKeybinding } from 'vs/base/common/keyCodes';
import { SubmenuAction } from 'vs/base/browser/ui/menu/menu'; import { SubmenuAction } from 'vs/base/browser/ui/menu/menu';
import { AnchorAlignment } from 'vs/base/browser/ui/contextview/contextview'; import { AnchorAlignment } from 'vs/base/browser/ui/contextview/contextview';
@@ -25,7 +25,7 @@ export class ContextSubMenu extends SubmenuAction {
export interface IContextMenuDelegate { export interface IContextMenuDelegate {
getAnchor(): HTMLElement | { x: number; y: number; width?: number; height?: number; }; getAnchor(): HTMLElement | { x: number; y: number; width?: number; height?: number; };
getActions(): Array<IAction | ContextSubMenu>; getActions(): Array<IAction | ContextSubMenu>;
getActionItem?(action: IAction): IActionItem | undefined; getActionViewItem?(action: IAction): IActionViewItem | undefined;
getActionsContext?(event?: IContextMenuEvent): any; getActionsContext?(event?: IContextMenuEvent): any;
getKeyBinding?(action: IAction): ResolvedKeybinding | undefined; getKeyBinding?(action: IAction): ResolvedKeybinding | undefined;
getMenuClassName?(): string; getMenuClassName?(): string;

View File

@@ -329,7 +329,7 @@ function parseFormattedText(content: string): IFormatParseTree {
children: [] children: []
}; };
let actionItemIndex = 0; let actionViewItemIndex = 0;
let current = root; let current = root;
const stack: IFormatParseTree[] = []; const stack: IFormatParseTree[] = [];
const stream = new StringStream(content); const stream = new StringStream(content);
@@ -359,8 +359,8 @@ function parseFormattedText(content: string): IFormatParseTree {
}; };
if (type === FormatType.Action) { if (type === FormatType.Action) {
newCurrent.index = actionItemIndex; newCurrent.index = actionViewItemIndex;
actionItemIndex++; actionViewItemIndex++;
} }
current.children!.push(newCurrent); current.children!.push(newCurrent);

View File

@@ -18,7 +18,7 @@ import { IContextViewProvider } from 'vs/base/browser/ui/contextview/contextview
import { Event, Emitter } from 'vs/base/common/event'; import { Event, Emitter } from 'vs/base/common/event';
import { asArray } from 'vs/base/common/arrays'; import { asArray } from 'vs/base/common/arrays';
export interface IActionItem { export interface IActionViewItem {
actionRunner: IActionRunner; actionRunner: IActionRunner;
setActionContext(context: any): void; setActionContext(context: any): void;
render(element: HTMLElement): void; render(element: HTMLElement): void;
@@ -28,12 +28,12 @@ export interface IActionItem {
dispose(): void; dispose(): void;
} }
export interface IBaseActionItemOptions { export interface IBaseActionViewItemOptions {
draggable?: boolean; draggable?: boolean;
isMenu?: boolean; isMenu?: boolean;
} }
export class BaseActionItem extends Disposable implements IActionItem { export class BaseActionViewItem extends Disposable implements IActionViewItem {
element?: HTMLElement; element?: HTMLElement;
_context: any; _context: any;
@@ -41,7 +41,7 @@ export class BaseActionItem extends Disposable implements IActionItem {
private _actionRunner: IActionRunner; private _actionRunner: IActionRunner;
constructor(context: any, action: IAction, protected options?: IBaseActionItemOptions) { constructor(context: any, action: IAction, protected options?: IBaseActionViewItemOptions) {
super(); super();
this._context = context || this; this._context = context || this;
@@ -226,20 +226,20 @@ export class Separator extends Action {
} }
} }
export interface IActionItemOptions extends IBaseActionItemOptions { export interface IActionViewItemOptions extends IBaseActionViewItemOptions {
icon?: boolean; icon?: boolean;
label?: boolean; label?: boolean;
keybinding?: string | null; keybinding?: string | null;
} }
export class ActionItem extends BaseActionItem { export class ActionViewItem extends BaseActionViewItem {
protected label: HTMLElement; protected label: HTMLElement;
protected options: IActionItemOptions; protected options: IActionViewItemOptions;
private cssClass?: string; private cssClass?: string;
constructor(context: any, action: IAction, options: IActionItemOptions = {}) { constructor(context: any, action: IAction, options: IActionViewItemOptions = {}) {
super(context, action, options); super(context, action, options);
this.options = options; this.options = options;
@@ -363,14 +363,14 @@ export interface ActionTrigger {
keyDown: boolean; keyDown: boolean;
} }
export interface IActionItemProvider { export interface IActionViewItemProvider {
(action: IAction): IActionItem | undefined; (action: IAction): IActionViewItem | undefined;
} }
export interface IActionBarOptions { export interface IActionBarOptions {
orientation?: ActionsOrientation; orientation?: ActionsOrientation;
context?: any; context?: any;
actionItemProvider?: IActionItemProvider; actionViewItemProvider?: IActionViewItemProvider;
actionRunner?: IActionRunner; actionRunner?: IActionRunner;
ariaLabel?: string; ariaLabel?: string;
animated?: boolean; animated?: boolean;
@@ -386,7 +386,7 @@ const defaultOptions: IActionBarOptions = {
} }
}; };
export interface IActionOptions extends IActionItemOptions { export interface IActionOptions extends IActionViewItemOptions {
index?: number; index?: number;
} }
@@ -397,8 +397,8 @@ export class ActionBar extends Disposable implements IActionRunner {
private _actionRunner: IActionRunner; private _actionRunner: IActionRunner;
private _context: any; private _context: any;
// Items // View Items
items: IActionItem[]; viewItems: IActionViewItem[];
protected focusedItem?: number; protected focusedItem?: number;
private focusTracker: DOM.IFocusTracker; private focusTracker: DOM.IFocusTracker;
@@ -438,7 +438,7 @@ export class ActionBar extends Disposable implements IActionRunner {
this._register(this._actionRunner.onDidRun(e => this._onDidRun.fire(e))); this._register(this._actionRunner.onDidRun(e => this._onDidRun.fire(e)));
this._register(this._actionRunner.onDidBeforeRun(e => this._onDidBeforeRun.fire(e))); this._register(this._actionRunner.onDidBeforeRun(e => this._onDidBeforeRun.fire(e)));
this.items = []; this.viewItems = [];
this.focusedItem = undefined; this.focusedItem = undefined;
this.domNode = document.createElement('div'); this.domNode = document.createElement('div');
@@ -575,7 +575,7 @@ export class ActionBar extends Disposable implements IActionRunner {
set context(context: any) { set context(context: any) {
this._context = context; this._context = context;
this.items.forEach(i => i.setActionContext(context)); this.viewItems.forEach(i => i.setActionContext(context));
} }
get actionRunner(): IActionRunner { get actionRunner(): IActionRunner {
@@ -585,7 +585,7 @@ export class ActionBar extends Disposable implements IActionRunner {
set actionRunner(actionRunner: IActionRunner) { set actionRunner(actionRunner: IActionRunner) {
if (actionRunner) { if (actionRunner) {
this._actionRunner = actionRunner; this._actionRunner = actionRunner;
this.items.forEach(item => item.actionRunner = actionRunner); this.viewItems.forEach(item => item.actionRunner = actionRunner);
} }
} }
@@ -599,36 +599,36 @@ export class ActionBar extends Disposable implements IActionRunner {
let index = types.isNumber(options.index) ? options.index : null; let index = types.isNumber(options.index) ? options.index : null;
actions.forEach((action: IAction) => { actions.forEach((action: IAction) => {
const actionItemElement = document.createElement('li'); const actionViewItemElement = document.createElement('li');
actionItemElement.className = 'action-item'; actionViewItemElement.className = 'action-item';
actionItemElement.setAttribute('role', 'presentation'); actionViewItemElement.setAttribute('role', 'presentation');
// Prevent native context menu on actions // Prevent native context menu on actions
this._register(DOM.addDisposableListener(actionItemElement, DOM.EventType.CONTEXT_MENU, (e: DOM.EventLike) => { this._register(DOM.addDisposableListener(actionViewItemElement, DOM.EventType.CONTEXT_MENU, (e: DOM.EventLike) => {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
})); }));
let item: IActionItem | undefined; let item: IActionViewItem | undefined;
if (this.options.actionItemProvider) { if (this.options.actionViewItemProvider) {
item = this.options.actionItemProvider(action); item = this.options.actionViewItemProvider(action);
} }
if (!item) { if (!item) {
item = new ActionItem(this.context, action, options); item = new ActionViewItem(this.context, action, options);
} }
item.actionRunner = this._actionRunner; item.actionRunner = this._actionRunner;
item.setActionContext(this.context); item.setActionContext(this.context);
item.render(actionItemElement); item.render(actionViewItemElement);
if (index === null || index < 0 || index >= this.actionsList.children.length) { if (index === null || index < 0 || index >= this.actionsList.children.length) {
this.actionsList.appendChild(actionItemElement); this.actionsList.appendChild(actionViewItemElement);
this.items.push(item); this.viewItems.push(item);
} else { } else {
this.actionsList.insertBefore(actionItemElement, this.actionsList.children[index]); this.actionsList.insertBefore(actionViewItemElement, this.actionsList.children[index]);
this.items.splice(index, 0, item); this.viewItems.splice(index, 0, item);
index++; index++;
} }
}); });
@@ -657,23 +657,23 @@ export class ActionBar extends Disposable implements IActionRunner {
} }
pull(index: number): void { pull(index: number): void {
if (index >= 0 && index < this.items.length) { if (index >= 0 && index < this.viewItems.length) {
this.actionsList.removeChild(this.actionsList.childNodes[index]); this.actionsList.removeChild(this.actionsList.childNodes[index]);
dispose(this.items.splice(index, 1)); dispose(this.viewItems.splice(index, 1));
} }
} }
clear(): void { clear(): void {
this.items = dispose(this.items); this.viewItems = dispose(this.viewItems);
DOM.clearNode(this.actionsList); DOM.clearNode(this.actionsList);
} }
length(): number { length(): number {
return this.items.length; return this.viewItems.length;
} }
isEmpty(): boolean { isEmpty(): boolean {
return this.items.length === 0; return this.viewItems.length === 0;
} }
focus(index?: number): void; focus(index?: number): void;
@@ -691,7 +691,7 @@ export class ActionBar extends Disposable implements IActionRunner {
if (selectFirst && typeof this.focusedItem === 'undefined') { if (selectFirst && typeof this.focusedItem === 'undefined') {
// Focus the first enabled item // Focus the first enabled item
this.focusedItem = this.items.length - 1; this.focusedItem = this.viewItems.length - 1;
this.focusNext(); this.focusNext();
} else { } else {
if (index !== undefined) { if (index !== undefined) {
@@ -704,15 +704,15 @@ export class ActionBar extends Disposable implements IActionRunner {
protected focusNext(): void { protected focusNext(): void {
if (typeof this.focusedItem === 'undefined') { if (typeof this.focusedItem === 'undefined') {
this.focusedItem = this.items.length - 1; this.focusedItem = this.viewItems.length - 1;
} }
const startIndex = this.focusedItem; const startIndex = this.focusedItem;
let item: IActionItem; let item: IActionViewItem;
do { do {
this.focusedItem = (this.focusedItem + 1) % this.items.length; this.focusedItem = (this.focusedItem + 1) % this.viewItems.length;
item = this.items[this.focusedItem]; item = this.viewItems[this.focusedItem];
} while (this.focusedItem !== startIndex && !item.isEnabled()); } while (this.focusedItem !== startIndex && !item.isEnabled());
if (this.focusedItem === startIndex && !item.isEnabled()) { if (this.focusedItem === startIndex && !item.isEnabled()) {
@@ -728,16 +728,16 @@ export class ActionBar extends Disposable implements IActionRunner {
} }
const startIndex = this.focusedItem; const startIndex = this.focusedItem;
let item: IActionItem; let item: IActionViewItem;
do { do {
this.focusedItem = this.focusedItem - 1; this.focusedItem = this.focusedItem - 1;
if (this.focusedItem < 0) { if (this.focusedItem < 0) {
this.focusedItem = this.items.length - 1; this.focusedItem = this.viewItems.length - 1;
} }
item = this.items[this.focusedItem]; item = this.viewItems[this.focusedItem];
} while (this.focusedItem !== startIndex && !item.isEnabled()); } while (this.focusedItem !== startIndex && !item.isEnabled());
if (this.focusedItem === startIndex && !item.isEnabled()) { if (this.focusedItem === startIndex && !item.isEnabled()) {
@@ -752,21 +752,21 @@ export class ActionBar extends Disposable implements IActionRunner {
this.actionsList.focus(); this.actionsList.focus();
} }
for (let i = 0; i < this.items.length; i++) { for (let i = 0; i < this.viewItems.length; i++) {
const item = this.items[i]; const item = this.viewItems[i];
const actionItem = item; const actionViewItem = item;
if (i === this.focusedItem) { if (i === this.focusedItem) {
if (types.isFunction(actionItem.isEnabled)) { if (types.isFunction(actionViewItem.isEnabled)) {
if (actionItem.isEnabled() && types.isFunction(actionItem.focus)) { if (actionViewItem.isEnabled() && types.isFunction(actionViewItem.focus)) {
actionItem.focus(fromRight); actionViewItem.focus(fromRight);
} else { } else {
this.actionsList.focus(); this.actionsList.focus();
} }
} }
} else { } else {
if (types.isFunction(actionItem.blur)) { if (types.isFunction(actionViewItem.blur)) {
actionItem.blur(); actionViewItem.blur();
} }
} }
} }
@@ -778,16 +778,16 @@ export class ActionBar extends Disposable implements IActionRunner {
} }
// trigger action // trigger action
const actionItem = this.items[this.focusedItem]; const actionViewItem = this.viewItems[this.focusedItem];
if (actionItem instanceof BaseActionItem) { if (actionViewItem instanceof BaseActionViewItem) {
const context = (actionItem._context === null || actionItem._context === undefined) ? event : actionItem._context; const context = (actionViewItem._context === null || actionViewItem._context === undefined) ? event : actionViewItem._context;
this.run(actionItem._action, context); this.run(actionViewItem._action, context);
} }
} }
private cancel(): void { private cancel(): void {
if (document.activeElement instanceof HTMLElement) { if (document.activeElement instanceof HTMLElement) {
(<HTMLElement>document.activeElement).blur(); // remove focus from focused action document.activeElement.blur(); // remove focus from focused action
} }
this._onDidCancel.fire(); this._onDidCancel.fire();
@@ -798,8 +798,8 @@ export class ActionBar extends Disposable implements IActionRunner {
} }
dispose(): void { dispose(): void {
dispose(this.items); dispose(this.viewItems);
this.items = []; this.viewItems = [];
DOM.removeNode(this.getContainer()); DOM.removeNode(this.getContainer());
@@ -807,7 +807,7 @@ export class ActionBar extends Disposable implements IActionRunner {
} }
} }
export class SelectActionItem extends BaseActionItem { export class SelectActionViewItem extends BaseActionViewItem {
protected selectBox: SelectBox; protected selectBox: SelectBox;
constructor(ctx: any, action: IAction, options: ISelectOptionItem[], selected: number, contextViewProvider: IContextViewProvider, selectBoxOptions?: ISelectBoxOptions) { constructor(ctx: any, action: IAction, options: ISelectOptionItem[], selected: number, contextViewProvider: IContextViewProvider, selectBoxOptions?: ISelectBoxOptions) {

View File

@@ -11,7 +11,7 @@ import { Color } from 'vs/base/common/color';
import { Emitter, Event } from 'vs/base/common/event'; import { Emitter, Event } from 'vs/base/common/event';
import { KeyCode } from 'vs/base/common/keyCodes'; import { KeyCode } from 'vs/base/common/keyCodes';
import * as objects from 'vs/base/common/objects'; import * as objects from 'vs/base/common/objects';
import { BaseActionItem } from 'vs/base/browser/ui/actionbar/actionbar'; import { BaseActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { IDisposable, dispose } from 'vs/base/common/lifecycle';
export interface ICheckboxOpts extends ICheckboxStyles { export interface ICheckboxOpts extends ICheckboxStyles {
@@ -28,7 +28,7 @@ const defaultOpts = {
inputActiveOptionBorder: Color.fromHex('#007ACC') inputActiveOptionBorder: Color.fromHex('#007ACC')
}; };
export class CheckboxActionItem extends BaseActionItem { export class CheckboxActionViewItem extends BaseActionViewItem {
private checkbox: Checkbox; private checkbox: Checkbox;
private disposables: IDisposable[] = []; private disposables: IDisposable[] = [];

View File

@@ -132,13 +132,13 @@ export class ContextView extends Disposable {
ContextView.BUBBLE_UP_EVENTS.forEach(event => { ContextView.BUBBLE_UP_EVENTS.forEach(event => {
toDisposeOnSetContainer.push(DOM.addStandardDisposableListener(this.container!, event, (e: Event) => { toDisposeOnSetContainer.push(DOM.addStandardDisposableListener(this.container!, event, (e: Event) => {
this.onDOMEvent(e, <HTMLElement>document.activeElement, false); this.onDOMEvent(e, false);
})); }));
}); });
ContextView.BUBBLE_DOWN_EVENTS.forEach(event => { ContextView.BUBBLE_DOWN_EVENTS.forEach(event => {
toDisposeOnSetContainer.push(DOM.addStandardDisposableListener(this.container!, event, (e: Event) => { toDisposeOnSetContainer.push(DOM.addStandardDisposableListener(this.container!, event, (e: Event) => {
this.onDOMEvent(e, <HTMLElement>document.activeElement, true); this.onDOMEvent(e, true);
}, true)); }, true));
}); });
@@ -213,13 +213,11 @@ export class ContextView extends Disposable {
height: elementPosition.height height: elementPosition.height
}; };
} else { } else {
let realAnchor = <IAnchor>anchor;
around = { around = {
top: realAnchor.y, top: anchor.y,
left: realAnchor.x, left: anchor.x,
width: realAnchor.width || 1, width: anchor.width || 1,
height: realAnchor.height || 2 height: anchor.height || 2
}; };
} }
@@ -278,7 +276,7 @@ export class ContextView extends Disposable {
return !!this.delegate; return !!this.delegate;
} }
private onDOMEvent(e: Event, element: HTMLElement, onCapture: boolean): void { private onDOMEvent(e: Event, onCapture: boolean): void {
if (this.delegate) { if (this.delegate) {
if (this.delegate.onDOMEvent) { if (this.delegate.onDOMEvent) {
this.delegate.onDOMEvent(e, <HTMLElement>document.activeElement); this.delegate.onDOMEvent(e, <HTMLElement>document.activeElement);

View File

@@ -6,7 +6,7 @@
import 'vs/css!./dropdown'; import 'vs/css!./dropdown';
import { Gesture, EventType as GestureEventType } from 'vs/base/browser/touch'; import { Gesture, EventType as GestureEventType } from 'vs/base/browser/touch';
import { ActionRunner, IAction, IActionRunner } from 'vs/base/common/actions'; import { ActionRunner, IAction, IActionRunner } from 'vs/base/common/actions';
import { BaseActionItem, IActionItemProvider } from 'vs/base/browser/ui/actionbar/actionbar'; import { BaseActionViewItem, IActionViewItemProvider } from 'vs/base/browser/ui/actionbar/actionbar';
import { IDisposable } from 'vs/base/common/lifecycle'; import { IDisposable } from 'vs/base/common/lifecycle';
import { IContextViewProvider, IAnchor, AnchorAlignment } from 'vs/base/browser/ui/contextview/contextview'; import { IContextViewProvider, IAnchor, AnchorAlignment } from 'vs/base/browser/ui/contextview/contextview';
import { IMenuOptions } from 'vs/base/browser/ui/menu/menu'; import { IMenuOptions } from 'vs/base/browser/ui/menu/menu';
@@ -247,7 +247,7 @@ export class DropdownMenu extends BaseDropdown {
getAnchor: () => this.element, getAnchor: () => this.element,
getActions: () => this.actions, getActions: () => this.actions,
getActionsContext: () => this.menuOptions ? this.menuOptions.context : null, getActionsContext: () => this.menuOptions ? this.menuOptions.context : null,
getActionItem: action => this.menuOptions && this.menuOptions.actionItemProvider ? this.menuOptions.actionItemProvider(action) : undefined, getActionViewItem: action => this.menuOptions && this.menuOptions.actionViewItemProvider ? this.menuOptions.actionViewItemProvider(action) : undefined,
getKeyBinding: action => this.menuOptions && this.menuOptions.getKeyBinding ? this.menuOptions.getKeyBinding(action) : undefined, getKeyBinding: action => this.menuOptions && this.menuOptions.getKeyBinding ? this.menuOptions.getKeyBinding(action) : undefined,
getMenuClassName: () => this.menuClassName, getMenuClassName: () => this.menuClassName,
onHide: () => this.onHide(), onHide: () => this.onHide(),
@@ -266,23 +266,23 @@ export class DropdownMenu extends BaseDropdown {
} }
} }
export class DropdownMenuActionItem extends BaseActionItem { export class DropdownMenuActionViewItem extends BaseActionViewItem {
private menuActionsOrProvider: any; private menuActionsOrProvider: any;
private dropdownMenu: DropdownMenu; private dropdownMenu: DropdownMenu;
private contextMenuProvider: IContextMenuProvider; private contextMenuProvider: IContextMenuProvider;
private actionItemProvider?: IActionItemProvider; private actionViewItemProvider?: IActionViewItemProvider;
private keybindings?: (action: IAction) => ResolvedKeybinding | undefined; private keybindings?: (action: IAction) => ResolvedKeybinding | undefined;
private clazz: string | undefined; private clazz: string | undefined;
private anchorAlignmentProvider: (() => AnchorAlignment) | undefined; private anchorAlignmentProvider: (() => AnchorAlignment) | undefined;
constructor(action: IAction, menuActions: IAction[], contextMenuProvider: IContextMenuProvider, actionItemProvider: IActionItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding | undefined) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment); constructor(action: IAction, menuActions: IAction[], contextMenuProvider: IContextMenuProvider, actionViewItemProvider: IActionViewItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding | undefined) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment);
constructor(action: IAction, actionProvider: IActionProvider, contextMenuProvider: IContextMenuProvider, actionItemProvider: IActionItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment); constructor(action: IAction, actionProvider: IActionProvider, contextMenuProvider: IContextMenuProvider, actionViewItemProvider: IActionViewItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment);
constructor(action: IAction, menuActionsOrProvider: any, contextMenuProvider: IContextMenuProvider, actionItemProvider: IActionItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding | undefined) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment) { constructor(action: IAction, menuActionsOrProvider: any, contextMenuProvider: IContextMenuProvider, actionViewItemProvider: IActionViewItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding | undefined) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment) {
super(null, action); super(null, action);
this.menuActionsOrProvider = menuActionsOrProvider; this.menuActionsOrProvider = menuActionsOrProvider;
this.contextMenuProvider = contextMenuProvider; this.contextMenuProvider = contextMenuProvider;
this.actionItemProvider = actionItemProvider; this.actionViewItemProvider = actionViewItemProvider;
this.actionRunner = actionRunner; this.actionRunner = actionRunner;
this.keybindings = keybindings; this.keybindings = keybindings;
this.clazz = clazz; this.clazz = clazz;
@@ -319,7 +319,7 @@ export class DropdownMenuActionItem extends BaseActionItem {
this.dropdownMenu = this._register(new DropdownMenu(container, options)); this.dropdownMenu = this._register(new DropdownMenu(container, options));
this.dropdownMenu.menuOptions = { this.dropdownMenu.menuOptions = {
actionItemProvider: this.actionItemProvider, actionViewItemProvider: this.actionViewItemProvider,
actionRunner: this.actionRunner, actionRunner: this.actionRunner,
getKeyBinding: this.keybindings, getKeyBinding: this.keybindings,
context: this._context context: this._context

View File

@@ -161,7 +161,7 @@ export class InputBox extends Widget {
let tagName = this.options.flexibleHeight ? 'textarea' : 'input'; let tagName = this.options.flexibleHeight ? 'textarea' : 'input';
let wrapper = dom.append(this.element, $('.wrapper')); let wrapper = dom.append(this.element, $('.wrapper'));
this.input = <HTMLInputElement>dom.append(wrapper, $(tagName + '.input')); this.input = dom.append(wrapper, $(tagName + '.input'));
this.input.setAttribute('autocorrect', 'off'); this.input.setAttribute('autocorrect', 'off');
this.input.setAttribute('autocapitalize', 'off'); this.input.setAttribute('autocapitalize', 'off');
this.input.setAttribute('spellcheck', 'false'); this.input.setAttribute('spellcheck', 'false');

View File

@@ -7,7 +7,7 @@ import 'vs/css!./menu';
import * as nls from 'vs/nls'; import * as nls from 'vs/nls';
import * as strings from 'vs/base/common/strings'; import * as strings from 'vs/base/common/strings';
import { IActionRunner, IAction, Action } from 'vs/base/common/actions'; import { IActionRunner, IAction, Action } from 'vs/base/common/actions';
import { ActionBar, IActionItemProvider, ActionsOrientation, Separator, ActionItem, IActionItemOptions, BaseActionItem } from 'vs/base/browser/ui/actionbar/actionbar'; import { ActionBar, IActionViewItemProvider, ActionsOrientation, Separator, ActionViewItem, IActionViewItemOptions, BaseActionViewItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { ResolvedKeybinding, KeyCode } from 'vs/base/common/keyCodes'; import { ResolvedKeybinding, KeyCode } from 'vs/base/common/keyCodes';
import { addClass, EventType, EventHelper, EventLike, removeTabIndexAndUpdateFocus, isAncestor, hasClass, addDisposableListener, removeClass, append, $, addClasses, removeClasses } from 'vs/base/browser/dom'; import { addClass, EventType, EventHelper, EventLike, removeTabIndexAndUpdateFocus, isAncestor, hasClass, addDisposableListener, removeClass, append, $, addClasses, removeClasses } from 'vs/base/browser/dom';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
@@ -39,7 +39,7 @@ export const MENU_ESCAPED_MNEMONIC_REGEX: RegExp = createMenuEscapedMnemonicRegE
export interface IMenuOptions { export interface IMenuOptions {
context?: any; context?: any;
actionItemProvider?: IActionItemProvider; actionViewItemProvider?: IActionViewItemProvider;
actionRunner?: IActionRunner; actionRunner?: IActionRunner;
getKeyBinding?: (action: IAction) => ResolvedKeybinding | undefined; getKeyBinding?: (action: IAction) => ResolvedKeybinding | undefined;
ariaLabel?: string; ariaLabel?: string;
@@ -70,7 +70,7 @@ interface ISubMenuData {
} }
export class Menu extends ActionBar { export class Menu extends ActionBar {
private mnemonics: Map<string, Array<MenuActionItem>>; private mnemonics: Map<string, Array<BaseMenuActionViewItem>>;
private menuDisposables: IDisposable[]; private menuDisposables: IDisposable[];
private scrollableElement: DomScrollableElement; private scrollableElement: DomScrollableElement;
private menuElement: HTMLElement; private menuElement: HTMLElement;
@@ -88,7 +88,7 @@ export class Menu extends ActionBar {
super(menuElement, { super(menuElement, {
orientation: ActionsOrientation.VERTICAL, orientation: ActionsOrientation.VERTICAL,
actionItemProvider: action => this.doGetActionItem(action, options, parentData), actionViewItemProvider: action => this.doGetActionViewItem(action, options, parentData),
context: options.context, context: options.context,
actionRunner: options.actionRunner, actionRunner: options.actionRunner,
ariaLabel: options.ariaLabel, ariaLabel: options.ariaLabel,
@@ -113,7 +113,7 @@ export class Menu extends ActionBar {
const actions = this.mnemonics.get(key)!; const actions = this.mnemonics.get(key)!;
if (actions.length === 1) { if (actions.length === 1) {
if (actions[0] instanceof SubmenuActionItem) { if (actions[0] instanceof SubmenuMenuActionViewItem) {
this.focusItemByElement(actions[0].container); this.focusItemByElement(actions[0].container);
} }
@@ -138,7 +138,7 @@ export class Menu extends ActionBar {
const event = new StandardKeyboardEvent(e); const event = new StandardKeyboardEvent(e);
if (event.equals(KeyCode.Home) || event.equals(KeyCode.PageUp)) { if (event.equals(KeyCode.Home) || event.equals(KeyCode.PageUp)) {
this.focusedItem = this.items.length - 1; this.focusedItem = this.viewItems.length - 1;
this.focusNext(); this.focusNext();
EventHelper.stop(e, true); EventHelper.stop(e, true);
} else if (event.equals(KeyCode.End) || event.equals(KeyCode.PageDown)) { } else if (event.equals(KeyCode.End) || event.equals(KeyCode.PageDown)) {
@@ -189,7 +189,7 @@ export class Menu extends ActionBar {
parent: this parent: this
}; };
this.mnemonics = new Map<string, Array<MenuActionItem>>(); this.mnemonics = new Map<string, Array<BaseMenuActionViewItem>>();
this.push(actions, { icon: true, label: true, isMenu: true }); this.push(actions, { icon: true, label: true, isMenu: true });
@@ -223,7 +223,7 @@ export class Menu extends ActionBar {
container.appendChild(this.scrollableElement.getDomNode()); container.appendChild(this.scrollableElement.getDomNode());
this.scrollableElement.scanDomNode(); this.scrollableElement.scanDomNode();
this.items.filter(item => !(item instanceof MenuSeparatorActionItem)).forEach((item: MenuActionItem, index: number, array: any[]) => { this.viewItems.filter(item => !(item instanceof MenuSeparatorActionViewItem)).forEach((item: BaseMenuActionViewItem, index: number, array: any[]) => {
item.updatePositionInSet(index + 1, array.length); item.updatePositionInSet(index + 1, array.length);
}); });
} }
@@ -241,9 +241,9 @@ export class Menu extends ActionBar {
this.domNode.style.backgroundColor = bgColor; this.domNode.style.backgroundColor = bgColor;
container.style.boxShadow = shadow; container.style.boxShadow = shadow;
if (this.items) { if (this.viewItems) {
this.items.forEach(item => { this.viewItems.forEach(item => {
if (item instanceof MenuActionItem || item instanceof MenuSeparatorActionItem) { if (item instanceof BaseMenuActionViewItem || item instanceof MenuSeparatorActionViewItem) {
item.style(style); item.style(style);
} }
}); });
@@ -263,12 +263,12 @@ export class Menu extends ActionBar {
} }
trigger(index: number): void { trigger(index: number): void {
if (index <= this.items.length && index >= 0) { if (index <= this.viewItems.length && index >= 0) {
const item = this.items[index]; const item = this.viewItems[index];
if (item instanceof SubmenuActionItem) { if (item instanceof SubmenuMenuActionViewItem) {
super.focus(index); super.focus(index);
item.open(true); item.open(true);
} else if (item instanceof MenuActionItem) { } else if (item instanceof BaseMenuActionViewItem) {
super.run(item._action, item._context); super.run(item._action, item._context);
} else { } else {
return; return;
@@ -295,27 +295,27 @@ export class Menu extends ActionBar {
} }
} }
private doGetActionItem(action: IAction, options: IMenuOptions, parentData: ISubMenuData): BaseActionItem { private doGetActionViewItem(action: IAction, options: IMenuOptions, parentData: ISubMenuData): BaseActionViewItem {
if (action instanceof Separator) { if (action instanceof Separator) {
return new MenuSeparatorActionItem(options.context, action, { icon: true }); return new MenuSeparatorActionViewItem(options.context, action, { icon: true });
} else if (action instanceof SubmenuAction) { } else if (action instanceof SubmenuAction) {
const menuActionItem = new SubmenuActionItem(action, action.entries, parentData, options); const menuActionViewItem = new SubmenuMenuActionViewItem(action, action.entries, parentData, options);
if (options.enableMnemonics) { if (options.enableMnemonics) {
const mnemonic = menuActionItem.getMnemonic(); const mnemonic = menuActionViewItem.getMnemonic();
if (mnemonic && menuActionItem.isEnabled()) { if (mnemonic && menuActionViewItem.isEnabled()) {
let actionItems: MenuActionItem[] = []; let actionViewItems: BaseMenuActionViewItem[] = [];
if (this.mnemonics.has(mnemonic)) { if (this.mnemonics.has(mnemonic)) {
actionItems = this.mnemonics.get(mnemonic)!; actionViewItems = this.mnemonics.get(mnemonic)!;
} }
actionItems.push(menuActionItem); actionViewItems.push(menuActionViewItem);
this.mnemonics.set(mnemonic, actionItems); this.mnemonics.set(mnemonic, actionViewItems);
} }
} }
return menuActionItem; return menuActionViewItem;
} else { } else {
const menuItemOptions: IMenuItemOptions = { enableMnemonics: options.enableMnemonics }; const menuItemOptions: IMenuItemOptions = { enableMnemonics: options.enableMnemonics };
if (options.getKeyBinding) { if (options.getKeyBinding) {
@@ -329,32 +329,32 @@ export class Menu extends ActionBar {
} }
} }
const menuActionItem = new MenuActionItem(options.context, action, menuItemOptions); const menuActionViewItem = new BaseMenuActionViewItem(options.context, action, menuItemOptions);
if (options.enableMnemonics) { if (options.enableMnemonics) {
const mnemonic = menuActionItem.getMnemonic(); const mnemonic = menuActionViewItem.getMnemonic();
if (mnemonic && menuActionItem.isEnabled()) { if (mnemonic && menuActionViewItem.isEnabled()) {
let actionItems: MenuActionItem[] = []; let actionViewItems: BaseMenuActionViewItem[] = [];
if (this.mnemonics.has(mnemonic)) { if (this.mnemonics.has(mnemonic)) {
actionItems = this.mnemonics.get(mnemonic)!; actionViewItems = this.mnemonics.get(mnemonic)!;
} }
actionItems.push(menuActionItem); actionViewItems.push(menuActionViewItem);
this.mnemonics.set(mnemonic, actionItems); this.mnemonics.set(mnemonic, actionViewItems);
} }
} }
return menuActionItem; return menuActionViewItem;
} }
} }
} }
interface IMenuItemOptions extends IActionItemOptions { interface IMenuItemOptions extends IActionViewItemOptions {
enableMnemonics?: boolean; enableMnemonics?: boolean;
} }
class MenuActionItem extends BaseActionItem { class BaseMenuActionViewItem extends BaseActionViewItem {
public container: HTMLElement; public container: HTMLElement;
@@ -562,7 +562,7 @@ class MenuActionItem extends BaseActionItem {
} }
} }
class SubmenuActionItem extends MenuActionItem { class SubmenuMenuActionViewItem extends BaseMenuActionViewItem {
private mysubmenu: Menu | null; private mysubmenu: Menu | null;
private submenuContainer: HTMLElement | undefined; private submenuContainer: HTMLElement | undefined;
private submenuIndicator: HTMLElement; private submenuIndicator: HTMLElement;
@@ -778,7 +778,7 @@ class SubmenuActionItem extends MenuActionItem {
} }
} }
class MenuSeparatorActionItem extends ActionItem { class MenuSeparatorActionViewItem extends ActionViewItem {
style(style: IMenuStyles): void { style(style: IMenuStyles): void {
this.label.style.borderBottomColor = style.separatorColor ? `${style.separatorColor}` : null; this.label.style.borderBottomColor = style.separatorColor ? `${style.separatorColor}` : null;
} }

View File

@@ -41,8 +41,8 @@ class SelectListRenderer implements IListRenderer<ISelectOptionItem, ISelectList
constructor() { } constructor() { }
renderTemplate(container: HTMLElement): any { renderTemplate(container: HTMLElement): ISelectListTemplateData {
const data = <ISelectListTemplateData>Object.create(null); const data: ISelectListTemplateData = Object.create(null);
data.disposables = []; data.disposables = [];
data.root = container; data.root = container;
data.text = dom.append(container, $('.option-text')); data.text = dom.append(container, $('.option-text'));
@@ -54,10 +54,10 @@ class SelectListRenderer implements IListRenderer<ISelectOptionItem, ISelectList
} }
renderElement(element: ISelectOptionItem, index: number, templateData: ISelectListTemplateData): void { renderElement(element: ISelectOptionItem, index: number, templateData: ISelectListTemplateData): void {
const data = <ISelectListTemplateData>templateData; const data: ISelectListTemplateData = templateData;
const text = (<ISelectOptionItem>element).text; const text = element.text;
const decoratorRight = (<ISelectOptionItem>element).decoratorRight; const decoratorRight = element.decoratorRight;
const isDisabled = (<ISelectOptionItem>element).isDisabled; const isDisabled = element.isDisabled;
data.text.textContent = text; data.text.textContent = text;
data.decoratorRight.innerText = (!!decoratorRight ? decoratorRight : ''); data.decoratorRight.innerText = (!!decoratorRight ? decoratorRight : '');
@@ -73,10 +73,10 @@ class SelectListRenderer implements IListRenderer<ISelectOptionItem, ISelectList
// pseudo-select disabled option // pseudo-select disabled option
if (isDisabled) { if (isDisabled) {
dom.addClass((<HTMLElement>data.root), 'option-disabled'); dom.addClass(data.root, 'option-disabled');
} else { } else {
// Make sure we do class removal from prior template rendering // Make sure we do class removal from prior template rendering
dom.removeClass((<HTMLElement>data.root), 'option-disabled'); dom.removeClass(data.root, 'option-disabled');
} }
} }
@@ -836,9 +836,9 @@ export class SelectBoxList implements ISelectBoxDelegate, IListVirtualDelegate<I
private renderDescriptionMarkdown(text: string): HTMLElement { private renderDescriptionMarkdown(text: string): HTMLElement {
const cleanRenderedMarkdown = (element: Node) => { const cleanRenderedMarkdown = (element: Node) => {
for (let i = 0; i < element.childNodes.length; i++) { for (let i = 0; i < element.childNodes.length; i++) {
const child = element.childNodes.item(i); const child = <Element>element.childNodes.item(i);
const tagName = (<Element>child).tagName && (<Element>child).tagName.toLowerCase(); const tagName = child.tagName && child.tagName.toLowerCase();
if (tagName === 'img') { if (tagName === 'img') {
element.removeChild(child); element.removeChild(child);
} else { } else {

View File

@@ -234,8 +234,8 @@ export class SplitView extends Disposable {
}); });
const sashEventMapper = this.orientation === Orientation.VERTICAL const sashEventMapper = this.orientation === Orientation.VERTICAL
? (e: IBaseSashEvent) => ({ sash, start: e.startY, current: e.currentY, alt: e.altKey } as ISashEvent) ? (e: IBaseSashEvent) => ({ sash, start: e.startY, current: e.currentY, alt: e.altKey })
: (e: IBaseSashEvent) => ({ sash, start: e.startX, current: e.currentX, alt: e.altKey } as ISashEvent); : (e: IBaseSashEvent) => ({ sash, start: e.startX, current: e.currentX, alt: e.altKey });
const onStart = Event.map(sash.onDidStart, sashEventMapper); const onStart = Event.map(sash.onDidStart, sashEventMapper);
const onStartDisposable = onStart(this.onSashStart, this); const onStartDisposable = onStart(this.onSashStart, this);

View File

@@ -6,8 +6,8 @@
import 'vs/css!./toolbar'; import 'vs/css!./toolbar';
import * as nls from 'vs/nls'; import * as nls from 'vs/nls';
import { Action, IActionRunner, IAction } from 'vs/base/common/actions'; import { Action, IActionRunner, IAction } from 'vs/base/common/actions';
import { ActionBar, ActionsOrientation, IActionItemProvider } from 'vs/base/browser/ui/actionbar/actionbar'; import { ActionBar, ActionsOrientation, IActionViewItemProvider } from 'vs/base/browser/ui/actionbar/actionbar';
import { IContextMenuProvider, DropdownMenuActionItem } from 'vs/base/browser/ui/dropdown/dropdown'; import { IContextMenuProvider, DropdownMenuActionViewItem } from 'vs/base/browser/ui/dropdown/dropdown';
import { ResolvedKeybinding } from 'vs/base/common/keyCodes'; import { ResolvedKeybinding } from 'vs/base/common/keyCodes';
import { Disposable } from 'vs/base/common/lifecycle'; import { Disposable } from 'vs/base/common/lifecycle';
import { AnchorAlignment } from 'vs/base/browser/ui/contextview/contextview'; import { AnchorAlignment } from 'vs/base/browser/ui/contextview/contextview';
@@ -17,7 +17,7 @@ export const CONTEXT = 'context.toolbar';
export interface IToolBarOptions { export interface IToolBarOptions {
orientation?: ActionsOrientation; orientation?: ActionsOrientation;
actionItemProvider?: IActionItemProvider; actionViewItemProvider?: IActionViewItemProvider;
ariaLabel?: string; ariaLabel?: string;
getKeyBinding?: (action: IAction) => ResolvedKeybinding | undefined; getKeyBinding?: (action: IAction) => ResolvedKeybinding | undefined;
actionRunner?: IActionRunner; actionRunner?: IActionRunner;
@@ -32,7 +32,7 @@ export class ToolBar extends Disposable {
private options: IToolBarOptions; private options: IToolBarOptions;
private actionBar: ActionBar; private actionBar: ActionBar;
private toggleMenuAction: ToggleMenuAction; private toggleMenuAction: ToggleMenuAction;
private toggleMenuActionItem?: DropdownMenuActionItem; private toggleMenuActionViewItem?: DropdownMenuActionViewItem;
private hasSecondaryActions: boolean; private hasSecondaryActions: boolean;
private lookupKeybindings: boolean; private lookupKeybindings: boolean;
@@ -42,7 +42,7 @@ export class ToolBar extends Disposable {
this.options = options; this.options = options;
this.lookupKeybindings = typeof this.options.getKeyBinding === 'function'; this.lookupKeybindings = typeof this.options.getKeyBinding === 'function';
this.toggleMenuAction = this._register(new ToggleMenuAction(() => this.toggleMenuActionItem && this.toggleMenuActionItem.show(), options.toggleMenuTitle)); this.toggleMenuAction = this._register(new ToggleMenuAction(() => this.toggleMenuActionViewItem && this.toggleMenuActionViewItem.show(), options.toggleMenuTitle));
let element = document.createElement('div'); let element = document.createElement('div');
element.className = 'monaco-toolbar'; element.className = 'monaco-toolbar';
@@ -52,33 +52,33 @@ export class ToolBar extends Disposable {
orientation: options.orientation, orientation: options.orientation,
ariaLabel: options.ariaLabel, ariaLabel: options.ariaLabel,
actionRunner: options.actionRunner, actionRunner: options.actionRunner,
actionItemProvider: (action: Action) => { actionViewItemProvider: (action: Action) => {
// Return special action item for the toggle menu action // Return special action item for the toggle menu action
if (action.id === ToggleMenuAction.ID) { if (action.id === ToggleMenuAction.ID) {
// Dispose old // Dispose old
if (this.toggleMenuActionItem) { if (this.toggleMenuActionViewItem) {
this.toggleMenuActionItem.dispose(); this.toggleMenuActionViewItem.dispose();
} }
// Create new // Create new
this.toggleMenuActionItem = new DropdownMenuActionItem( this.toggleMenuActionViewItem = new DropdownMenuActionViewItem(
action, action,
(<ToggleMenuAction>action).menuActions, (<ToggleMenuAction>action).menuActions,
contextMenuProvider, contextMenuProvider,
this.options.actionItemProvider, this.options.actionViewItemProvider,
this.actionRunner, this.actionRunner,
this.options.getKeyBinding, this.options.getKeyBinding,
'toolbar-toggle-more', 'toolbar-toggle-more',
this.options.anchorAlignmentProvider this.options.anchorAlignmentProvider
); );
this.toggleMenuActionItem!.setActionContext(this.actionBar.context); this.toggleMenuActionViewItem!.setActionContext(this.actionBar.context);
return this.toggleMenuActionItem; return this.toggleMenuActionViewItem;
} }
return options.actionItemProvider ? options.actionItemProvider(action) : undefined; return options.actionViewItemProvider ? options.actionViewItemProvider(action) : undefined;
} }
})); }));
} }
@@ -93,8 +93,8 @@ export class ToolBar extends Disposable {
set context(context: any) { set context(context: any) {
this.actionBar.context = context; this.actionBar.context = context;
if (this.toggleMenuActionItem) { if (this.toggleMenuActionViewItem) {
this.toggleMenuActionItem.setActionContext(context); this.toggleMenuActionViewItem.setActionContext(context);
} }
} }
@@ -156,9 +156,9 @@ export class ToolBar extends Disposable {
} }
dispose(): void { dispose(): void {
if (this.toggleMenuActionItem) { if (this.toggleMenuActionViewItem) {
this.toggleMenuActionItem.dispose(); this.toggleMenuActionViewItem.dispose();
this.toggleMenuActionItem = undefined; this.toggleMenuActionViewItem = undefined;
} }
super.dispose(); super.dispose();

View File

@@ -29,7 +29,7 @@ export interface IActionRunner extends IDisposable {
onDidBeforeRun: Event<IRunEvent>; onDidBeforeRun: Event<IRunEvent>;
} }
export interface IActionItem { export interface IActionViewItem {
actionRunner: IActionRunner; actionRunner: IActionRunner;
setActionContext(context: any): void; setActionContext(context: any): void;
render(element: any /* HTMLElement */): void; render(element: any /* HTMLElement */): void;

View File

@@ -79,7 +79,7 @@ export function getFirstFrame(arg0: IRemoteConsoleLog | string | undefined): ISt
uri: URI.file(matches[1]), uri: URI.file(matches[1]),
line: Number(matches[2]), line: Number(matches[2]),
column: Number(matches[3]) column: Number(matches[3])
} as IStackFrame; };
} }
} }

View File

@@ -139,19 +139,22 @@ export function isUNC(path: string): boolean {
} }
// Reference: https://en.wikipedia.org/wiki/Filename // Reference: https://en.wikipedia.org/wiki/Filename
const INVALID_FILE_CHARS = isWindows ? /[\\/:\*\?"<>\|]/g : /[\\/]/g; const WINDOWS_INVALID_FILE_CHARS = /[\\/:\*\?"<>\|]/g;
const UNIX_INVALID_FILE_CHARS = /[\\/]/g;
const WINDOWS_FORBIDDEN_NAMES = /^(con|prn|aux|clock\$|nul|lpt[0-9]|com[0-9])$/i; const WINDOWS_FORBIDDEN_NAMES = /^(con|prn|aux|clock\$|nul|lpt[0-9]|com[0-9])$/i;
export function isValidBasename(name: string | null | undefined): boolean { export function isValidBasename(name: string | null | undefined, isWindowsOS: boolean = isWindows): boolean {
const invalidFileChars = isWindowsOS ? WINDOWS_INVALID_FILE_CHARS : UNIX_INVALID_FILE_CHARS;
if (!name || name.length === 0 || /^\s+$/.test(name)) { if (!name || name.length === 0 || /^\s+$/.test(name)) {
return false; // require a name that is not just whitespace return false; // require a name that is not just whitespace
} }
INVALID_FILE_CHARS.lastIndex = 0; // the holy grail of software development invalidFileChars.lastIndex = 0; // the holy grail of software development
if (INVALID_FILE_CHARS.test(name)) { if (invalidFileChars.test(name)) {
return false; // check for certain invalid file characters return false; // check for certain invalid file characters
} }
if (isWindows && WINDOWS_FORBIDDEN_NAMES.test(name)) { if (isWindowsOS && WINDOWS_FORBIDDEN_NAMES.test(name)) {
return false; // check for certain invalid file names return false; // check for certain invalid file names
} }
@@ -159,16 +162,16 @@ export function isValidBasename(name: string | null | undefined): boolean {
return false; // check for reserved values return false; // check for reserved values
} }
if (isWindows && name[name.length - 1] === '.') { if (isWindowsOS && name[name.length - 1] === '.') {
return false; // Windows: file cannot end with a "." return false; // Windows: file cannot end with a "."
} }
if (isWindows && name.length !== name.trim().length) { if (isWindowsOS && name.length !== name.trim().length) {
return false; // Windows: file cannot end with a whitespace return false; // Windows: file cannot end with a whitespace
} }
if (name.length > 255) { if (name.length > 255) {
return false; // most file systems do not allow files > 255 lenth return false; // most file systems do not allow files > 255 length
} }
return true; return true;

View File

@@ -197,7 +197,11 @@ function guessMimeTypeByFirstline(firstLine: string): string | null {
} }
if (firstLine.length > 0) { if (firstLine.length > 0) {
for (const association of registeredAssociations) {
// We want to prioritize associations based on the order they are registered so that the last registered
// association wins over all other. This is for https://github.com/Microsoft/vscode/issues/20074
for (let i = registeredAssociations.length - 1; i >= 0; i--) {
const association = registeredAssociations[i];
if (!association.firstline) { if (!association.firstline) {
continue; continue;
} }
@@ -230,10 +234,11 @@ export function isUnspecific(mime: string[] | string): boolean {
* 2. Otherwise, if there are other extensions, suggest the first one. * 2. Otherwise, if there are other extensions, suggest the first one.
* 3. Otherwise, suggest the prefix. * 3. Otherwise, suggest the prefix.
*/ */
export function suggestFilename(langId: string | null, prefix: string): string { export function suggestFilename(mode: string | undefined, prefix: string): string {
const extensions = registeredAssociations const extensions = registeredAssociations
.filter(assoc => !assoc.userConfigured && assoc.extension && assoc.id === langId) .filter(assoc => !assoc.userConfigured && assoc.extension && assoc.id === mode)
.map(assoc => assoc.extension); .map(assoc => assoc.extension);
const extensionsWithDotFirst = coalesce(extensions) const extensionsWithDotFirst = coalesce(extensions)
.filter(assoc => startsWith(assoc, '.')); .filter(assoc => startsWith(assoc, '.'));

View File

@@ -14,7 +14,7 @@ export function deepClone<T>(obj: T): T {
return obj as any; return obj as any;
} }
const result: any = Array.isArray(obj) ? [] : {}; const result: any = Array.isArray(obj) ? [] : {};
Object.keys(obj).forEach((key: string) => { Object.keys(obj as any).forEach((key: string) => {
if (obj[key] && typeof obj[key] === 'object') { if (obj[key] && typeof obj[key] === 'object') {
result[key] = deepClone(obj[key]); result[key] = deepClone(obj[key]);
} else { } else {

View File

@@ -79,7 +79,7 @@ export abstract class Parser {
this._problemReporter.fatal(message); this._problemReporter.fatal(message);
} }
protected static merge<T>(destination: T, source: T, overwrite: boolean): void { protected static merge<T extends object>(destination: T, source: T, overwrite: boolean): void {
Object.keys(source).forEach((key: string) => { Object.keys(source).forEach((key: string) => {
const destValue = destination[key]; const destValue = destination[key];
const sourceValue = source[key]; const sourceValue = source[key];

View File

@@ -176,28 +176,46 @@ export function isAbsolutePath(resource: URI): boolean {
/** /**
* Returns true if the URI path has a trailing path separator * Returns true if the URI path has a trailing path separator
*/ */
export function hasTrailingPathSeparator(resource: URI): boolean { export function hasTrailingPathSeparator(resource: URI, sep: string = paths.sep): boolean {
if (resource.scheme === Schemas.file) { if (resource.scheme === Schemas.file) {
const fsp = originalFSPath(resource); const fsp = originalFSPath(resource);
return fsp.length > extpath.getRoot(fsp).length && fsp[fsp.length - 1] === paths.sep; return fsp.length > extpath.getRoot(fsp).length && fsp[fsp.length - 1] === sep;
} else { } else {
const p = resource.path; const p = resource.path;
return p.length > 1 && p.charCodeAt(p.length - 1) === CharCode.Slash; // ignore the slash at offset 0 return p.length > 1 && p.charCodeAt(p.length - 1) === CharCode.Slash; // ignore the slash at offset 0
} }
} }
/** /**
* Removes a trailing path seperator, if theres one. * Removes a trailing path separator, if there's one.
* Important: Doesn't remove the first slash, it would make the URI invalid * Important: Doesn't remove the first slash, it would make the URI invalid
*/ */
export function removeTrailingPathSeparator(resource: URI): URI { export function removeTrailingPathSeparator(resource: URI, sep: string = paths.sep): URI {
if (hasTrailingPathSeparator(resource)) { if (hasTrailingPathSeparator(resource, sep)) {
return resource.with({ path: resource.path.substr(0, resource.path.length - 1) }); return resource.with({ path: resource.path.substr(0, resource.path.length - 1) });
} }
return resource; return resource;
} }
/**
* Adds a trailing path separator to the URI if there isn't one already.
* For example, c:\ would be unchanged, but c:\users would become c:\users\
*/
export function addTrailingPathSeparator(resource: URI, sep: string = paths.sep): URI {
let isRootSep: boolean = false;
if (resource.scheme === Schemas.file) {
const fsp = originalFSPath(resource);
isRootSep = ((fsp !== undefined) && (fsp.length === extpath.getRoot(fsp).length) && (fsp[fsp.length - 1] === sep));
} else {
sep = '/';
const p = resource.path;
isRootSep = p.length === 1 && p.charCodeAt(p.length - 1) === CharCode.Slash;
}
if (!isRootSep && !hasTrailingPathSeparator(resource, sep)) {
return resource.with({ path: resource.path + '/' });
}
return resource;
}
/** /**
* Returns a relative path between two URIs. If the URIs don't have the same schema or authority, `undefined` is returned. * Returns a relative path between two URIs. If the URIs don't have the same schema or authority, `undefined` is returned.

View File

@@ -233,7 +233,7 @@ export function regExpLeadsToEndlessLoop(regexp: RegExp): boolean {
// We check against an empty string. If the regular expression doesn't advance // We check against an empty string. If the regular expression doesn't advance
// (e.g. ends in an endless loop) it will match an empty string. // (e.g. ends in an endless loop) it will match an empty string.
const match = regexp.exec(''); const match = regexp.exec('');
return !!(match && <any>regexp.lastIndex === 0); return !!(match && regexp.lastIndex === 0);
} }
export function regExpContainsBackreference(regexpValue: string): boolean { export function regExpContainsBackreference(regexpValue: string): boolean {

View File

@@ -670,4 +670,15 @@ export async function mkdirp(path: string, mode?: number, token?: CancellationTo
// Any other error // Any other error
return Promise.reject(error); return Promise.reject(error);
} }
} }
// See https://github.com/Microsoft/vscode/issues/30180
const WIN32_MAX_FILE_SIZE = 300 * 1024 * 1024; // 300 MB
const GENERAL_MAX_FILE_SIZE = 16 * 1024 * 1024 * 1024; // 16 GB
// See https://github.com/v8/v8/blob/5918a23a3d571b9625e5cce246bdd5b46ff7cd8b/src/heap/heap.cc#L149
const WIN32_MAX_HEAP_SIZE = 700 * 1024 * 1024; // 700 MB
const GENERAL_MAX_HEAP_SIZE = 700 * 2 * 1024 * 1024; // 1400 MB
export const MAX_FILE_SIZE = process.arch === 'ia32' ? WIN32_MAX_FILE_SIZE : GENERAL_MAX_FILE_SIZE;
export const MAX_HEAP_SIZE = process.arch === 'ia32' ? WIN32_MAX_HEAP_SIZE : GENERAL_MAX_HEAP_SIZE;

View File

@@ -159,7 +159,7 @@ export function asText(context: IRequestContext): Promise<string | null> {
}); });
} }
export function asJson<T>(context: IRequestContext): Promise<T | null> { export function asJson<T = {}>(context: IRequestContext): Promise<T | null> {
return new Promise((c, e) => { return new Promise((c, e) => {
if (!isSuccess(context)) { if (!isSuccess(context)) {
return e('Server returned ' + context.res.statusCode); return e('Server returned ' + context.res.statusCode);

View File

@@ -218,7 +218,7 @@ class ProtocolReader extends Disposable {
// save new state => next time will read the body // save new state => next time will read the body
this._state.readHead = false; this._state.readHead = false;
this._state.readLen = buff.readUInt32BE(9); this._state.readLen = buff.readUInt32BE(9);
this._state.messageType = <ProtocolMessageType>buff.readUInt8(0); this._state.messageType = buff.readUInt8(0);
this._state.id = buff.readUInt32BE(1); this._state.id = buff.readUInt32BE(1);
this._state.ack = buff.readUInt32BE(5); this._state.ack = buff.readUInt32BE(5);
} else { } else {

View File

@@ -36,11 +36,11 @@ let IDS = 0;
export class QuickOpenItemAccessorClass implements IItemAccessor<QuickOpenEntry> { export class QuickOpenItemAccessorClass implements IItemAccessor<QuickOpenEntry> {
getItemLabel(entry: QuickOpenEntry): string | null { getItemLabel(entry: QuickOpenEntry): string | null {
return entry.getLabel(); return types.withUndefinedAsNull(entry.getLabel());
} }
getItemDescription(entry: QuickOpenEntry): string | null { getItemDescription(entry: QuickOpenEntry): string | null {
return entry.getDescription(); return types.withUndefinedAsNull(entry.getDescription());
} }
getItemPath(entry: QuickOpenEntry): string | undefined { getItemPath(entry: QuickOpenEntry): string | undefined {
@@ -75,15 +75,15 @@ export class QuickOpenEntry {
/** /**
* The label of the entry to identify it from others in the list * The label of the entry to identify it from others in the list
*/ */
getLabel(): string | null { getLabel(): string | undefined {
return null; return undefined;
} }
/** /**
* The options for the label to use for this entry * The options for the label to use for this entry
*/ */
getLabelOptions(): IIconLabelValueOptions | null { getLabelOptions(): IIconLabelValueOptions | undefined {
return null; return undefined;
} }
/** /**
@@ -97,51 +97,51 @@ export class QuickOpenEntry {
/** /**
* Detail information about the entry that is optional and can be shown below the label * Detail information about the entry that is optional and can be shown below the label
*/ */
getDetail(): string | null { getDetail(): string | undefined {
return null; return undefined;
} }
/** /**
* The icon of the entry to identify it from others in the list * The icon of the entry to identify it from others in the list
*/ */
getIcon(): string | null { getIcon(): string | undefined {
return null; return undefined;
} }
/** /**
* A secondary description that is optional and can be shown right to the label * A secondary description that is optional and can be shown right to the label
*/ */
getDescription(): string | null { getDescription(): string | undefined {
return null; return undefined;
} }
/** /**
* A tooltip to show when hovering over the entry. * A tooltip to show when hovering over the entry.
*/ */
getTooltip(): string | null { getTooltip(): string | undefined {
return null; return undefined;
} }
/** /**
* A tooltip to show when hovering over the description portion of the entry. * A tooltip to show when hovering over the description portion of the entry.
*/ */
getDescriptionTooltip(): string | null { getDescriptionTooltip(): string | undefined {
return null; return undefined;
} }
/** /**
* An optional keybinding to show for an entry. * An optional keybinding to show for an entry.
*/ */
getKeybinding(): ResolvedKeybinding | null { getKeybinding(): ResolvedKeybinding | undefined {
return null; return undefined;
} }
/** /**
* A resource for this entry. Resource URIs can be used to compare different kinds of entries and group * A resource for this entry. Resource URIs can be used to compare different kinds of entries and group
* them together. * them together.
*/ */
getResource(): URI | null { getResource(): URI | undefined {
return null; return undefined;
} }
/** /**
@@ -229,11 +229,11 @@ export class QuickOpenEntryGroup extends QuickOpenEntry {
this.withBorder = showBorder; this.withBorder = showBorder;
} }
getLabel(): string | null { getLabel(): string | undefined {
return this.entry ? this.entry.getLabel() : super.getLabel(); return this.entry ? this.entry.getLabel() : super.getLabel();
} }
getLabelOptions(): IIconLabelValueOptions | null { getLabelOptions(): IIconLabelValueOptions | undefined {
return this.entry ? this.entry.getLabelOptions() : super.getLabelOptions(); return this.entry ? this.entry.getLabelOptions() : super.getLabelOptions();
} }
@@ -241,19 +241,19 @@ export class QuickOpenEntryGroup extends QuickOpenEntry {
return this.entry ? this.entry.getAriaLabel() : super.getAriaLabel(); return this.entry ? this.entry.getAriaLabel() : super.getAriaLabel();
} }
getDetail(): string | null { getDetail(): string | undefined {
return this.entry ? this.entry.getDetail() : super.getDetail(); return this.entry ? this.entry.getDetail() : super.getDetail();
} }
getResource(): URI | null { getResource(): URI | undefined {
return this.entry ? this.entry.getResource() : super.getResource(); return this.entry ? this.entry.getResource() : super.getResource();
} }
getIcon(): string | null { getIcon(): string | undefined {
return this.entry ? this.entry.getIcon() : super.getIcon(); return this.entry ? this.entry.getIcon() : super.getIcon();
} }
getDescription(): string | null { getDescription(): string | undefined {
return this.entry ? this.entry.getDescription() : super.getDescription(); return this.entry ? this.entry.getDescription() : super.getDescription();
} }
@@ -459,13 +459,13 @@ class Renderer implements IRenderer<QuickOpenEntry> {
// Label // Label
const options: IIconLabelValueOptions = entry.getLabelOptions() || Object.create(null); const options: IIconLabelValueOptions = entry.getLabelOptions() || Object.create(null);
options.matches = labelHighlights || []; options.matches = labelHighlights || [];
options.title = types.withNullAsUndefined(entry.getTooltip()); options.title = entry.getTooltip();
options.descriptionTitle = entry.getDescriptionTooltip() || types.withNullAsUndefined(entry.getDescription()); // tooltip over description because it could overflow options.descriptionTitle = entry.getDescriptionTooltip() || entry.getDescription(); // tooltip over description because it could overflow
options.descriptionMatches = descriptionHighlights || []; options.descriptionMatches = descriptionHighlights || [];
data.label.setLabel(types.withNullAsUndefined(entry.getLabel()), types.withNullAsUndefined(entry.getDescription()), options); data.label.setLabel(types.withNullAsUndefined(entry.getLabel()), entry.getDescription(), options);
// Meta // Meta
data.detail.set(types.withNullAsUndefined(entry.getDetail()), detailHighlights); data.detail.set(entry.getDetail(), detailHighlights);
// Keybinding // Keybinding
data.keybinding.set(entry.getKeybinding()!); data.keybinding.set(entry.getKeybinding()!);
@@ -556,7 +556,7 @@ export class QuickOpenModel implements
} }
getLabel(entry: QuickOpenEntry): string | null { getLabel(entry: QuickOpenEntry): string | null {
return entry.getLabel(); return types.withUndefinedAsNull(entry.getLabel());
} }
getAriaLabel(entry: QuickOpenEntry): string { getAriaLabel(entry: QuickOpenEntry): string {

View File

@@ -6,6 +6,7 @@ import * as assert from 'assert';
import { guessMimeTypes, registerTextMime, suggestFilename } from 'vs/base/common/mime'; import { guessMimeTypes, registerTextMime, suggestFilename } from 'vs/base/common/mime';
suite('Mime', () => { suite('Mime', () => {
test('Dynamically Register Text Mime', () => { test('Dynamically Register Text Mime', () => {
let guess = guessMimeTypes('foo.monaco'); let guess = guessMimeTypes('foo.monaco');
assert.deepEqual(guess, ['application/unknown']); assert.deepEqual(guess, ['application/unknown']);
@@ -56,6 +57,11 @@ suite('Mime', () => {
registerTextMime({ id: 'docker', filepattern: 'dockerfile*', mime: 'text/looser' }); registerTextMime({ id: 'docker', filepattern: 'dockerfile*', mime: 'text/looser' });
guess = guessMimeTypes('dockerfile'); guess = guessMimeTypes('dockerfile');
assert.deepEqual(guess, ['text/winner', 'text/plain']); assert.deepEqual(guess, ['text/winner', 'text/plain']);
registerTextMime({ id: 'azure-looser', mime: 'text/azure-looser', firstline: /azure/ });
registerTextMime({ id: 'azure-winner', mime: 'text/azure-winner', firstline: /azure/ });
guess = guessMimeTypes('azure', 'azure');
assert.deepEqual(guess, ['text/azure-winner', 'text/plain']);
}); });
test('Specificity priority 1', () => { test('Specificity priority 1', () => {

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 * as assert from 'assert'; import * as assert from 'assert';
import { dirname, basename, distinctParents, joinPath, isEqual, isEqualOrParent, hasToIgnoreCase, normalizePath, isAbsolutePath, relativePath, removeTrailingPathSeparator, hasTrailingPathSeparator, resolvePath } from 'vs/base/common/resources'; import { dirname, basename, distinctParents, joinPath, isEqual, isEqualOrParent, hasToIgnoreCase, normalizePath, isAbsolutePath, relativePath, removeTrailingPathSeparator, hasTrailingPathSeparator, resolvePath, addTrailingPathSeparator } from 'vs/base/common/resources';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import { isWindows } from 'vs/base/common/platform'; import { isWindows } from 'vs/base/common/platform';
import { toSlashes } from 'vs/base/common/extpath'; import { toSlashes } from 'vs/base/common/extpath';
@@ -178,6 +178,9 @@ suite('Resources', () => {
assertEqualURI(removeTrailingPathSeparator(u1), expected, u1.toString()); assertEqualURI(removeTrailingPathSeparator(u1), expected, u1.toString());
} }
function assertAddTrailingSeparator(u1: URI, expected: URI) {
assertEqualURI(addTrailingPathSeparator(u1), expected, u1.toString());
}
test('trailingPathSeparator', () => { test('trailingPathSeparator', () => {
assertTrailingSeparator(URI.parse('foo://a/foo'), false); assertTrailingSeparator(URI.parse('foo://a/foo'), false);
@@ -190,6 +193,11 @@ suite('Resources', () => {
assertRemoveTrailingSeparator(URI.parse('foo://a/'), URI.parse('foo://a/')); assertRemoveTrailingSeparator(URI.parse('foo://a/'), URI.parse('foo://a/'));
assertRemoveTrailingSeparator(URI.parse('foo://a'), URI.parse('foo://a')); assertRemoveTrailingSeparator(URI.parse('foo://a'), URI.parse('foo://a'));
assertAddTrailingSeparator(URI.parse('foo://a/foo'), URI.parse('foo://a/foo/'));
assertAddTrailingSeparator(URI.parse('foo://a/foo/'), URI.parse('foo://a/foo/'));
assertAddTrailingSeparator(URI.parse('foo://a/'), URI.parse('foo://a/'));
assertAddTrailingSeparator(URI.parse('foo://a'), URI.parse('foo://a/'));
if (isWindows) { if (isWindows) {
assertTrailingSeparator(URI.file('c:\\a\\foo'), false); assertTrailingSeparator(URI.file('c:\\a\\foo'), false);
assertTrailingSeparator(URI.file('c:\\a\\foo\\'), true); assertTrailingSeparator(URI.file('c:\\a\\foo\\'), true);
@@ -202,6 +210,12 @@ suite('Resources', () => {
assertRemoveTrailingSeparator(URI.file('c:\\'), URI.file('c:\\')); assertRemoveTrailingSeparator(URI.file('c:\\'), URI.file('c:\\'));
assertRemoveTrailingSeparator(URI.file('\\\\server\\share\\some\\'), URI.file('\\\\server\\share\\some')); assertRemoveTrailingSeparator(URI.file('\\\\server\\share\\some\\'), URI.file('\\\\server\\share\\some'));
assertRemoveTrailingSeparator(URI.file('\\\\server\\share\\'), URI.file('\\\\server\\share\\')); assertRemoveTrailingSeparator(URI.file('\\\\server\\share\\'), URI.file('\\\\server\\share\\'));
assertAddTrailingSeparator(URI.file('c:\\a\\foo'), URI.file('c:\\a\\foo\\'));
assertAddTrailingSeparator(URI.file('c:\\a\\foo\\'), URI.file('c:\\a\\foo\\'));
assertAddTrailingSeparator(URI.file('c:\\'), URI.file('c:\\'));
assertAddTrailingSeparator(URI.file('\\\\server\\share\\some'), URI.file('\\\\server\\share\\some\\'));
assertAddTrailingSeparator(URI.file('\\\\server\\share\\some\\'), URI.file('\\\\server\\share\\some\\'));
} else { } else {
assertTrailingSeparator(URI.file('/foo/bar'), false); assertTrailingSeparator(URI.file('/foo/bar'), false);
assertTrailingSeparator(URI.file('/foo/bar/'), true); assertTrailingSeparator(URI.file('/foo/bar/'), true);
@@ -210,12 +224,16 @@ suite('Resources', () => {
assertRemoveTrailingSeparator(URI.file('/foo/bar'), URI.file('/foo/bar')); assertRemoveTrailingSeparator(URI.file('/foo/bar'), URI.file('/foo/bar'));
assertRemoveTrailingSeparator(URI.file('/foo/bar/'), URI.file('/foo/bar')); assertRemoveTrailingSeparator(URI.file('/foo/bar/'), URI.file('/foo/bar'));
assertRemoveTrailingSeparator(URI.file('/'), URI.file('/')); assertRemoveTrailingSeparator(URI.file('/'), URI.file('/'));
assertAddTrailingSeparator(URI.file('/foo/bar'), URI.file('/foo/bar/'));
assertAddTrailingSeparator(URI.file('/foo/bar/'), URI.file('/foo/bar/'));
assertAddTrailingSeparator(URI.file('/'), URI.file('/'));
} }
}); });
function assertEqualURI(actual: URI, expected: URI, message?: string) { function assertEqualURI(actual: URI, expected: URI, message?: string) {
if (!isEqual(expected, actual)) { if (!isEqual(expected, actual)) {
assert.equal(expected.toString(), actual.toString(), message); assert.equal(actual.toString(), expected.toString(), message);
} }
} }

View File

@@ -20,7 +20,7 @@ suite('Config', () => {
const newDir = path.join(parentDir, 'config', id); const newDir = path.join(parentDir, 'config', id);
const testFile = path.join(newDir, 'config.json'); const testFile = path.join(newDir, 'config.json');
let watcher = new ConfigWatcher(testFile); let watcher = new ConfigWatcher<{}>(testFile);
let config = watcher.getConfig(); let config = watcher.getConfig();
assert.ok(config); assert.ok(config);

View File

@@ -0,0 +1,15 @@
<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<!-- Disable pinch zooming -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
</head>
<body class="vs-dark" aria-label="">
</body>
<!-- Startup via workbench.js -->
<script src="../../../../../out/vs/code/browser/workbench/workbench.js"></script>
</html>

View File

@@ -0,0 +1,40 @@
/*---------------------------------------------------------------------------------------------
* 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 () {
function loadScript(path, callback) {
let script = document.createElement('script');
script.onload = callback;
script.async = true;
script.type = 'text/javascript';
script.src = path;
document.head.appendChild(script);
}
loadScript('../../../../../out/vs/loader.js', function () {
// @ts-ignore
require.config({
baseUrl: `${window.location.origin}/out`
});
// @ts-ignore
require([
'vs/workbench/workbench.web.main',
'vs/nls!vs/workbench/workbench.web.main',
'vs/css!vs/workbench/workbench.web.main'
],
// @ts-ignore
function () {
// @ts-ignore
require('vs/workbench/browser/web.main').main().then(undefined, console.error);
});
});
})();

View File

@@ -106,8 +106,8 @@ function showPartsSplash(configuration) {
const style = document.createElement('style'); const style = document.createElement('style');
style.className = 'initialShellColors'; style.className = 'initialShellColors';
document.head.appendChild(style); document.head.appendChild(style);
document.body.className = `monaco-shell ${baseTheme}`; document.body.className = baseTheme;
style.innerHTML = `.monaco-shell { background-color: ${shellBackground}; color: ${shellForeground}; }`; style.innerHTML = `body { background-color: ${shellBackground}; color: ${shellForeground}; }`;
if (data && data.layoutInfo) { if (data && data.layoutInfo) {
// restore parts if possible (we might not always store layout info) // restore parts if possible (we might not always store layout info)

View File

@@ -1,12 +0,0 @@
<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
</head>
<body class="monaco-shell vs-dark" aria-label="">
</body>
<!-- Startup via workbench.nodeless.js -->
<script src="workbench.nodeless.js"></script>
</html>

View File

@@ -1,67 +0,0 @@
/*---------------------------------------------------------------------------------------------
* 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 () {
function uriFromPath(_path) {
let pathName = _path.replace(/\\/g, '/');
if (pathName.length > 0 && pathName.charAt(0) !== '/') {
pathName = '/' + pathName;
}
let uri;
if (navigator.userAgent.indexOf('Windows') >= 0 && pathName.startsWith('//')) { // specially handle Windows UNC paths
uri = encodeURI('file:' + pathName);
} else {
uri = encodeURI('file://' + pathName);
}
return uri.replace(/#/g, '%23');
}
function parseURLQueryArgs() {
const search = window.location.search || '';
return search.split(/[?&]/)
.filter(function (param) { return !!param; })
.map(function (param) { return param.split('='); })
.filter(function (param) { return param.length === 2; })
.reduce(function (r, param) { r[param[0]] = decodeURIComponent(param[1]); return r; }, {});
}
function loadScript(path, callback) {
let script = document.createElement('script');
script.onload = callback;
script.async = true;
script.type = 'text/javascript';
script.src = path;
document.head.appendChild(script);
}
loadScript('../../../../../out/vs/loader.js', function () {
const args = parseURLQueryArgs();
const configuration = JSON.parse(args['config'] || '{}') || {};
// @ts-ignore
require.config({
baseUrl: uriFromPath(configuration.appRoot) + '/out',
});
// @ts-ignore
require([
'vs/workbench/workbench.nodeless.main',
'vs/nls!vs/workbench/workbench.nodeless.main',
'vs/css!vs/workbench/workbench.nodeless.main'
], function () {
// @ts-ignore
require('vs/workbench/browser/nodeless.main').main().then(undefined, console.error);
});
});
})();

View File

@@ -234,7 +234,7 @@ export class CodeApplication extends Disposable {
ipc.on('vscode:fetchShellEnv', (event: Event) => { ipc.on('vscode:fetchShellEnv', (event: Event) => {
const webContents = event.sender; const webContents = event.sender;
getShellEnvironment().then(shellEnv => { getShellEnvironment(this.logService).then(shellEnv => {
if (!webContents.isDestroyed()) { if (!webContents.isDestroyed()) {
webContents.send('vscode:acceptShellEnv', shellEnv); webContents.send('vscode:acceptShellEnv', shellEnv);
} }
@@ -678,7 +678,7 @@ export class CodeApplication extends Disposable {
historyMainService.onRecentlyOpenedChange(() => historyMainService.updateWindowsJumpList()); historyMainService.onRecentlyOpenedChange(() => historyMainService.updateWindowsJumpList());
// Start shared process after a while // Start shared process after a while
const sharedProcessSpawn = this._register(new RunOnceScheduler(() => getShellEnvironment().then(userEnv => this.sharedProcess.spawn(userEnv)), 3000)); const sharedProcessSpawn = this._register(new RunOnceScheduler(() => getShellEnvironment(this.logService).then(userEnv => this.sharedProcess.spawn(userEnv)), 3000));
sharedProcessSpawn.schedule(); sharedProcessSpawn.schedule();
} }

View File

@@ -55,7 +55,7 @@ function setupIPC(accessor: ServicesAccessor): Promise<Server> {
logService.trace('Sending some foreground love to the running instance:', processId); logService.trace('Sending some foreground love to the running instance:', processId);
try { try {
const { allowSetForegroundWindow } = <any>require.__$__nodeRequire('windows-foreground-love'); const { allowSetForegroundWindow } = require.__$__nodeRequire('windows-foreground-love');
allowSetForegroundWindow(processId); allowSetForegroundWindow(processId);
} catch (e) { } catch (e) {
// noop // noop

View File

@@ -8,7 +8,7 @@ import * as objects from 'vs/base/common/objects';
import * as nls from 'vs/nls'; import * as nls from 'vs/nls';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import { IStateService } from 'vs/platform/state/common/state'; import { IStateService } from 'vs/platform/state/common/state';
import { screen, BrowserWindow, systemPreferences, app, TouchBar, nativeImage } from 'electron'; import { screen, BrowserWindow, systemPreferences, app, TouchBar, nativeImage, Rectangle, Display } from 'electron';
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment'; import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
import { ILogService } from 'vs/platform/log/common/log'; import { ILogService } from 'vs/platform/log/common/log';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
@@ -25,7 +25,6 @@ import * as perf from 'vs/base/common/performance';
import { resolveMarketplaceHeaders } from 'vs/platform/extensionManagement/node/extensionGalleryService'; import { resolveMarketplaceHeaders } from 'vs/platform/extensionManagement/node/extensionGalleryService';
import { getBackgroundColor } from 'vs/code/electron-main/theme'; import { getBackgroundColor } from 'vs/code/electron-main/theme';
import { RunOnceScheduler } from 'vs/base/common/async'; import { RunOnceScheduler } from 'vs/base/common/async';
import { withNullAsUndefined } from 'vs/base/common/types';
import { endsWith } from 'vs/base/common/strings'; import { endsWith } from 'vs/base/common/strings';
export interface IWindowCreationOptions { export interface IWindowCreationOptions {
@@ -80,8 +79,6 @@ export class CodeWindow extends Disposable implements ICodeWindow {
private readonly touchBarGroups: Electron.TouchBarSegmentedControl[]; private readonly touchBarGroups: Electron.TouchBarSegmentedControl[];
private nodeless: boolean;
constructor( constructor(
config: IWindowCreationOptions, config: IWindowCreationOptions,
@ILogService private readonly logService: ILogService, @ILogService private readonly logService: ILogService,
@@ -98,8 +95,6 @@ export class CodeWindow extends Disposable implements ICodeWindow {
this._readyState = ReadyState.NONE; this._readyState = ReadyState.NONE;
this.whenReadyCallbacks = []; this.whenReadyCallbacks = [];
this.nodeless = !!(environmentService.args.nodeless && !environmentService.isBuilt);
// create browser window // create browser window
this.createBrowserWindow(config); this.createBrowserWindow(config);
@@ -129,7 +124,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
height: this.windowState.height, height: this.windowState.height,
x: this.windowState.x, x: this.windowState.x,
y: this.windowState.y, y: this.windowState.y,
backgroundColor: this.nodeless ? undefined : getBackgroundColor(this.stateService), backgroundColor: getBackgroundColor(this.stateService),
minWidth: CodeWindow.MIN_WIDTH, minWidth: CodeWindow.MIN_WIDTH,
minHeight: CodeWindow.MIN_HEIGHT, minHeight: CodeWindow.MIN_HEIGHT,
show: !isFullscreenOrMaximized, show: !isFullscreenOrMaximized,
@@ -143,10 +138,6 @@ export class CodeWindow extends Disposable implements ICodeWindow {
} }
}; };
if (this.nodeless) {
options.webPreferences!.nodeIntegration = false; // simulate Electron 5 behaviour
}
if (isLinux) { if (isLinux) {
options.icon = path.join(this.environmentService.appRoot, 'resources/linux/code.png'); // Windows and Mac are better off using the embedded icon(s) options.icon = path.join(this.environmentService.appRoot, 'resources/linux/code.png'); // Windows and Mac are better off using the embedded icon(s)
} }
@@ -201,10 +192,6 @@ export class CodeWindow extends Disposable implements ICodeWindow {
} }
} }
if (this.nodeless) {
this._win.webContents.toggleDevTools();
}
this._lastFocusTime = Date.now(); // since we show directly, we need to set the last focus time too this._lastFocusTime = Date.now(); // since we show directly, we need to set the last focus time too
} }
@@ -640,10 +627,6 @@ export class CodeWindow extends Disposable implements ICodeWindow {
} }
private doGetUrl(config: object): string { private doGetUrl(config: object): string {
if (this.nodeless) {
return `${require.toUrl('vs/code/electron-browser/workbench/workbench.nodeless.html')}?config=${encodeURIComponent(JSON.stringify(config))}`;
}
return `${require.toUrl('vs/code/electron-browser/workbench/workbench.html')}?config=${encodeURIComponent(JSON.stringify(config))}`; return `${require.toUrl('vs/code/electron-browser/workbench/workbench.html')}?config=${encodeURIComponent(JSON.stringify(config))}`;
} }
@@ -709,66 +692,55 @@ export class CodeWindow extends Disposable implements ICodeWindow {
private restoreWindowState(state?: IWindowState): IWindowState { private restoreWindowState(state?: IWindowState): IWindowState {
if (state) { if (state) {
try { try {
state = withNullAsUndefined(this.validateWindowState(state)); state = this.validateWindowState(state);
} catch (err) { } catch (err) {
this.logService.warn(`Unexpected error validating window state: ${err}\n${err.stack}`); // somehow display API can be picky about the state to validate this.logService.warn(`Unexpected error validating window state: ${err}\n${err.stack}`); // somehow display API can be picky about the state to validate
} }
} }
return state || defaultWindowState();
if (!state) {
state = defaultWindowState();
}
return state;
} }
private validateWindowState(state: IWindowState): IWindowState | null { private validateWindowState(state: IWindowState): IWindowState | undefined {
if (!state) {
return null;
}
if (typeof state.x !== 'number' if (typeof state.x !== 'number'
|| typeof state.y !== 'number' || typeof state.y !== 'number'
|| typeof state.width !== 'number' || typeof state.width !== 'number'
|| typeof state.height !== 'number' || typeof state.height !== 'number'
) { ) {
return null; return undefined;
} }
if (state.width <= 0 || state.height <= 0) { if (state.width <= 0 || state.height <= 0) {
return null; return undefined;
} }
const displays = screen.getAllDisplays(); const displays = screen.getAllDisplays();
// Single Monitor: be strict about x/y positioning // Single Monitor: be strict about x/y positioning
if (displays.length === 1) { if (displays.length === 1) {
const displayBounds = displays[0].bounds; const displayWorkingArea = this.getWorkingArea(displays[0]);
if (state.mode !== WindowMode.Maximized && displayWorkingArea) {
// Careful with maximized: in that mode x/y can well be negative! if (state.x < displayWorkingArea.x) {
if (state.mode !== WindowMode.Maximized && displayBounds.width > 0 && displayBounds.height > 0 /* Linux X11 sessions sometimes report wrong display bounds */) { state.x = displayWorkingArea.x; // prevent window from falling out of the screen to the left
if (state.x < displayBounds.x) {
state.x = displayBounds.x; // prevent window from falling out of the screen to the left
} }
if (state.y < displayBounds.y) { if (state.y < displayWorkingArea.y) {
state.y = displayBounds.y; // prevent window from falling out of the screen to the top state.y = displayWorkingArea.y; // prevent window from falling out of the screen to the top
} }
if (state.x > (displayBounds.x + displayBounds.width)) { if (state.x > (displayWorkingArea.x + displayWorkingArea.width)) {
state.x = displayBounds.x; // prevent window from falling out of the screen to the right state.x = displayWorkingArea.x; // prevent window from falling out of the screen to the right
} }
if (state.y > (displayBounds.y + displayBounds.height)) { if (state.y > (displayWorkingArea.y + displayWorkingArea.height)) {
state.y = displayBounds.y; // prevent window from falling out of the screen to the bottom state.y = displayWorkingArea.y; // prevent window from falling out of the screen to the bottom
} }
if (state.width > displayBounds.width) { if (state.width > displayWorkingArea.width) {
state.width = displayBounds.width; // prevent window from exceeding display bounds width state.width = displayWorkingArea.width; // prevent window from exceeding display bounds width
} }
if (state.height > displayBounds.height) { if (state.height > displayWorkingArea.height) {
state.height = displayBounds.height; // prevent window from exceeding display bounds height state.height = displayWorkingArea.height; // prevent window from exceeding display bounds height
} }
} }
@@ -794,12 +766,14 @@ export class CodeWindow extends Disposable implements ICodeWindow {
// Multi Monitor (non-fullscreen): be less strict because metrics can be crazy // Multi Monitor (non-fullscreen): be less strict because metrics can be crazy
const bounds = { x: state.x, y: state.y, width: state.width, height: state.height }; const bounds = { x: state.x, y: state.y, width: state.width, height: state.height };
const display = screen.getDisplayMatching(bounds); const display = screen.getDisplayMatching(bounds);
const displayWorkingArea = this.getWorkingArea(display);
if ( if (
display && // we have a display matching the desired bounds display && // we have a display matching the desired bounds
bounds.x < display.bounds.x + display.bounds.width && // prevent window from falling out of the screen to the right displayWorkingArea && // we have valid working area bounds
bounds.y < display.bounds.y + display.bounds.height && // prevent window from falling out of the screen to the bottom bounds.x < displayWorkingArea.x + displayWorkingArea.width && // prevent window from falling out of the screen to the right
bounds.x + bounds.width > display.bounds.x && // prevent window from falling out of the screen to the left bounds.y < displayWorkingArea.y + displayWorkingArea.height && // prevent window from falling out of the screen to the bottom
bounds.y + bounds.height > display.bounds.y // prevent window from falling out of the scree nto the top bounds.x + bounds.width > displayWorkingArea.x && // prevent window from falling out of the screen to the left
bounds.y + bounds.height > displayWorkingArea.y // prevent window from falling out of the scree nto the top
) { ) {
if (state.mode === WindowMode.Maximized) { if (state.mode === WindowMode.Maximized) {
const defaults = defaultWindowState(WindowMode.Maximized); // when maximized, make sure we have good values when the user restores the window const defaults = defaultWindowState(WindowMode.Maximized); // when maximized, make sure we have good values when the user restores the window
@@ -812,7 +786,25 @@ export class CodeWindow extends Disposable implements ICodeWindow {
return state; return state;
} }
return null; return undefined;
}
private getWorkingArea(display: Display): Rectangle | undefined {
// Prefer the working area of the display to account for taskbars on the
// desktop being positioned somewhere (https://github.com/Microsoft/vscode/issues/50830).
//
// Linux X11 sessions sometimes report wrong display bounds, so we validate
// the reported sizes are positive.
if (display.workArea.width > 0 && display.workArea.height > 0) {
return display.workArea;
}
if (display.bounds.width > 0 && display.bounds.height > 0) {
return display.bounds;
}
return undefined;
} }
getBounds(): Electron.Rectangle { getBounds(): Electron.Rectangle {

View File

@@ -112,6 +112,10 @@ export class Main {
private async installExtensions(extensions: string[], force: boolean): Promise<void> { private async installExtensions(extensions: string[], force: boolean): Promise<void> {
const failed: string[] = []; const failed: string[] = [];
const installedExtensionsManifests: IExtensionManifest[] = []; const installedExtensionsManifests: IExtensionManifest[] = [];
if (extensions.length) {
console.log(localize('installingExtensions', "Installing extensions..."));
}
for (const extension of extensions) { for (const extension of extensions) {
try { try {
const manifest = await this.installExtension(extension, force); const manifest = await this.installExtension(extension, force);
@@ -142,11 +146,11 @@ export class Main {
if (valid) { if (valid) {
return this.extensionManagementService.install(URI.file(extension)).then(id => { return this.extensionManagementService.install(URI.file(extension)).then(id => {
console.log(localize('successVsixInstall', "Extension '{0}' was successfully installed!", getBaseLabel(extension))); console.log(localize('successVsixInstall', "Extension '{0}' was successfully installed.", getBaseLabel(extension)));
return manifest; return manifest;
}, error => { }, error => {
if (isPromiseCanceledError(error)) { if (isPromiseCanceledError(error)) {
console.log(localize('cancelVsixInstall', "Cancelled installing Extension '{0}'.", getBaseLabel(extension))); console.log(localize('cancelVsixInstall', "Cancelled installing extension '{0}'.", getBaseLabel(extension)));
return null; return null;
} else { } else {
return Promise.reject(error); return Promise.reject(error);
@@ -191,9 +195,7 @@ export class Main {
console.log(localize('forceUpdate', "Extension '{0}' v{1} is already installed, but a newer version {2} is available in the marketplace. Use '--force' option to update to newer version.", id, installedExtension.manifest.version, extension.version)); console.log(localize('forceUpdate', "Extension '{0}' v{1} is already installed, but a newer version {2} is available in the marketplace. Use '--force' option to update to newer version.", id, installedExtension.manifest.version, extension.version));
return Promise.resolve(null); return Promise.resolve(null);
} }
console.log(localize('updateMessage', "Updating the Extension '{0}' to the version {1}", id, extension.version)); console.log(localize('updateMessage', "Updating the extension '{0}' to the version {1}", id, extension.version));
} else {
console.log(localize('foundExtension', "Found '{0}' in the marketplace.", id));
} }
await this.installFromGallery(id, extension); await this.installFromGallery(id, extension);
return manifest; return manifest;
@@ -210,7 +212,7 @@ export class Main {
const newer = installedExtensions.filter(local => areSameExtensions(extensionIdentifier, local.identifier) && semver.gt(local.manifest.version, manifest.version))[0]; const newer = installedExtensions.filter(local => areSameExtensions(extensionIdentifier, local.identifier) && semver.gt(local.manifest.version, manifest.version))[0];
if (newer && !force) { if (newer && !force) {
console.log(localize('forceDowngrade', "A newer version of this extension '{0}' v{1} is already installed. Use '--force' option to downgrade to older version.", newer.identifier.id, newer.manifest.version, manifest.version)); console.log(localize('forceDowngrade', "A newer version of extension '{0}' v{1} is already installed. Use '--force' option to downgrade to older version.", newer.identifier.id, newer.manifest.version, manifest.version));
return false; return false;
} }
@@ -218,14 +220,14 @@ export class Main {
} }
private async installFromGallery(id: string, extension: IGalleryExtension): Promise<void> { private async installFromGallery(id: string, extension: IGalleryExtension): Promise<void> {
console.log(localize('installing', "Installing...")); console.log(localize('installing', "Installing extension '{0}' v{1}...", id, extension.version));
try { try {
await this.extensionManagementService.installFromGallery(extension); await this.extensionManagementService.installFromGallery(extension);
console.log(localize('successInstall', "Extension '{0}' v{1} was successfully installed!", id, extension.version)); console.log(localize('successInstall', "Extension '{0}' v{1} was successfully installed.", id, extension.version));
} catch (error) { } catch (error) {
if (isPromiseCanceledError(error)) { if (isPromiseCanceledError(error)) {
console.log(localize('cancelVsixInstall', "Cancelled installing Extension '{0}'.", id)); console.log(localize('cancelVsixInstall', "Cancelled installing extension '{0}'.", id));
} else { } else {
throw error; throw error;
} }

View File

@@ -7,11 +7,16 @@ import * as cp from 'child_process';
import { assign } from 'vs/base/common/objects'; import { assign } from 'vs/base/common/objects';
import { generateUuid } from 'vs/base/common/uuid'; import { generateUuid } from 'vs/base/common/uuid';
import { isWindows } from 'vs/base/common/platform'; import { isWindows } from 'vs/base/common/platform';
import { ILogService } from 'vs/platform/log/common/log';
function getUnixShellEnvironment(): Promise<typeof process.env> { function getUnixShellEnvironment(logService: ILogService): Promise<typeof process.env> {
const promise = new Promise<typeof process.env>((resolve, reject) => { const promise = new Promise<typeof process.env>((resolve, reject) => {
const runAsNode = process.env['ELECTRON_RUN_AS_NODE']; const runAsNode = process.env['ELECTRON_RUN_AS_NODE'];
logService.trace('getUnixShellEnvironment#runAsNode', runAsNode);
const noAttach = process.env['ELECTRON_NO_ATTACH_CONSOLE']; const noAttach = process.env['ELECTRON_NO_ATTACH_CONSOLE'];
logService.trace('getUnixShellEnvironment#noAttach', noAttach);
const mark = generateUuid().replace(/-/g, '').substr(0, 12); const mark = generateUuid().replace(/-/g, '').substr(0, 12);
const regex = new RegExp(mark + '(.*)' + mark); const regex = new RegExp(mark + '(.*)' + mark);
@@ -21,6 +26,9 @@ function getUnixShellEnvironment(): Promise<typeof process.env> {
}); });
const command = `'${process.execPath}' -p '"${mark}" + JSON.stringify(process.env) + "${mark}"'`; const command = `'${process.execPath}' -p '"${mark}" + JSON.stringify(process.env) + "${mark}"'`;
logService.trace('getUnixShellEnvironment#env', env);
logService.trace('getUnixShellEnvironment#spawn', command);
const child = cp.spawn(process.env.SHELL!, ['-ilc', command], { const child = cp.spawn(process.env.SHELL!, ['-ilc', command], {
detached: true, detached: true,
stdio: ['ignore', 'pipe', process.stderr], stdio: ['ignore', 'pipe', process.stderr],
@@ -37,6 +45,8 @@ function getUnixShellEnvironment(): Promise<typeof process.env> {
} }
const raw = Buffer.concat(buffers).toString('utf8'); const raw = Buffer.concat(buffers).toString('utf8');
logService.trace('getUnixShellEnvironment#raw', raw);
const match = regex.exec(raw); const match = regex.exec(raw);
const rawStripped = match ? match[1] : '{}'; const rawStripped = match ? match[1] : '{}';
@@ -58,8 +68,10 @@ function getUnixShellEnvironment(): Promise<typeof process.env> {
// https://github.com/Microsoft/vscode/issues/22593#issuecomment-336050758 // https://github.com/Microsoft/vscode/issues/22593#issuecomment-336050758
delete env['XDG_RUNTIME_DIR']; delete env['XDG_RUNTIME_DIR'];
logService.trace('getUnixShellEnvironment#result', env);
resolve(env); resolve(env);
} catch (err) { } catch (err) {
logService.error('getUnixShellEnvironment#error', err);
reject(err); reject(err);
} }
}); });
@@ -77,14 +89,17 @@ let _shellEnv: Promise<typeof process.env>;
* This should only be done when Code itself is not launched * This should only be done when Code itself is not launched
* from within a shell. * from within a shell.
*/ */
export function getShellEnvironment(): Promise<typeof process.env> { export function getShellEnvironment(logService: ILogService): Promise<typeof process.env> {
if (_shellEnv === undefined) { if (_shellEnv === undefined) {
if (isWindows) { if (isWindows) {
logService.trace('getShellEnvironment: runing on windows, skipping');
_shellEnv = Promise.resolve({}); _shellEnv = Promise.resolve({});
} else if (process.env['VSCODE_CLI'] === '1') { } else if (process.env['VSCODE_CLI'] === '1') {
logService.trace('getShellEnvironment: runing on CLI, skipping');
_shellEnv = Promise.resolve({}); _shellEnv = Promise.resolve({});
} else { } else {
_shellEnv = getUnixShellEnvironment(); logService.trace('getShellEnvironment: running on Unix');
_shellEnv = getUnixShellEnvironment(logService);
} }
} }

View File

@@ -301,13 +301,13 @@ export namespace CoreNavigationCommands {
export const MoveTo: CoreEditorCommand = registerEditorCommand(new BaseMoveToCommand({ export const MoveTo: CoreEditorCommand = registerEditorCommand(new BaseMoveToCommand({
id: '_moveTo', id: '_moveTo',
inSelectionMode: false, inSelectionMode: false,
precondition: null precondition: undefined
})); }));
export const MoveToSelect: CoreEditorCommand = registerEditorCommand(new BaseMoveToCommand({ export const MoveToSelect: CoreEditorCommand = registerEditorCommand(new BaseMoveToCommand({
id: '_moveToSelect', id: '_moveToSelect',
inSelectionMode: true, inSelectionMode: true,
precondition: null precondition: undefined
})); }));
abstract class ColumnSelectCommand extends CoreEditorCommand { abstract class ColumnSelectCommand extends CoreEditorCommand {
@@ -330,7 +330,7 @@ export namespace CoreNavigationCommands {
constructor() { constructor() {
super({ super({
id: 'columnSelect', id: 'columnSelect',
precondition: null precondition: undefined
}); });
} }
@@ -354,7 +354,7 @@ export namespace CoreNavigationCommands {
constructor() { constructor() {
super({ super({
id: 'cursorColumnSelectLeft', id: 'cursorColumnSelectLeft',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -373,7 +373,7 @@ export namespace CoreNavigationCommands {
constructor() { constructor() {
super({ super({
id: 'cursorColumnSelectRight', id: 'cursorColumnSelectRight',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -405,7 +405,7 @@ export namespace CoreNavigationCommands {
export const CursorColumnSelectUp: CoreEditorCommand = registerEditorCommand(new ColumnSelectUpCommand({ export const CursorColumnSelectUp: CoreEditorCommand = registerEditorCommand(new ColumnSelectUpCommand({
isPaged: false, isPaged: false,
id: 'cursorColumnSelectUp', id: 'cursorColumnSelectUp',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -417,7 +417,7 @@ export namespace CoreNavigationCommands {
export const CursorColumnSelectPageUp: CoreEditorCommand = registerEditorCommand(new ColumnSelectUpCommand({ export const CursorColumnSelectPageUp: CoreEditorCommand = registerEditorCommand(new ColumnSelectUpCommand({
isPaged: true, isPaged: true,
id: 'cursorColumnSelectPageUp', id: 'cursorColumnSelectPageUp',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -443,7 +443,7 @@ export namespace CoreNavigationCommands {
export const CursorColumnSelectDown: CoreEditorCommand = registerEditorCommand(new ColumnSelectDownCommand({ export const CursorColumnSelectDown: CoreEditorCommand = registerEditorCommand(new ColumnSelectDownCommand({
isPaged: false, isPaged: false,
id: 'cursorColumnSelectDown', id: 'cursorColumnSelectDown',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -455,7 +455,7 @@ export namespace CoreNavigationCommands {
export const CursorColumnSelectPageDown: CoreEditorCommand = registerEditorCommand(new ColumnSelectDownCommand({ export const CursorColumnSelectPageDown: CoreEditorCommand = registerEditorCommand(new ColumnSelectDownCommand({
isPaged: true, isPaged: true,
id: 'cursorColumnSelectPageDown', id: 'cursorColumnSelectPageDown',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -468,7 +468,7 @@ export namespace CoreNavigationCommands {
constructor() { constructor() {
super({ super({
id: 'cursorMove', id: 'cursorMove',
precondition: null, precondition: undefined,
description: CursorMove_.description description: CursorMove_.description
}); });
} }
@@ -531,7 +531,7 @@ export namespace CoreNavigationCommands {
value: 1 value: 1
}, },
id: 'cursorLeft', id: 'cursorLeft',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -548,7 +548,7 @@ export namespace CoreNavigationCommands {
value: 1 value: 1
}, },
id: 'cursorLeftSelect', id: 'cursorLeftSelect',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -564,7 +564,7 @@ export namespace CoreNavigationCommands {
value: 1 value: 1
}, },
id: 'cursorRight', id: 'cursorRight',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -581,7 +581,7 @@ export namespace CoreNavigationCommands {
value: 1 value: 1
}, },
id: 'cursorRightSelect', id: 'cursorRightSelect',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -597,7 +597,7 @@ export namespace CoreNavigationCommands {
value: 1 value: 1
}, },
id: 'cursorUp', id: 'cursorUp',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -614,7 +614,7 @@ export namespace CoreNavigationCommands {
value: 1 value: 1
}, },
id: 'cursorUpSelect', id: 'cursorUpSelect',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -633,7 +633,7 @@ export namespace CoreNavigationCommands {
value: Constants.PAGE_SIZE_MARKER value: Constants.PAGE_SIZE_MARKER
}, },
id: 'cursorPageUp', id: 'cursorPageUp',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -649,7 +649,7 @@ export namespace CoreNavigationCommands {
value: Constants.PAGE_SIZE_MARKER value: Constants.PAGE_SIZE_MARKER
}, },
id: 'cursorPageUpSelect', id: 'cursorPageUpSelect',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -665,7 +665,7 @@ export namespace CoreNavigationCommands {
value: 1 value: 1
}, },
id: 'cursorDown', id: 'cursorDown',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -682,7 +682,7 @@ export namespace CoreNavigationCommands {
value: 1 value: 1
}, },
id: 'cursorDownSelect', id: 'cursorDownSelect',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -701,7 +701,7 @@ export namespace CoreNavigationCommands {
value: Constants.PAGE_SIZE_MARKER value: Constants.PAGE_SIZE_MARKER
}, },
id: 'cursorPageDown', id: 'cursorPageDown',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -717,7 +717,7 @@ export namespace CoreNavigationCommands {
value: Constants.PAGE_SIZE_MARKER value: Constants.PAGE_SIZE_MARKER
}, },
id: 'cursorPageDownSelect', id: 'cursorPageDownSelect',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -729,7 +729,7 @@ export namespace CoreNavigationCommands {
constructor() { constructor() {
super({ super({
id: 'createCursor', id: 'createCursor',
precondition: null precondition: undefined
}); });
} }
@@ -790,7 +790,7 @@ export namespace CoreNavigationCommands {
constructor() { constructor() {
super({ super({
id: '_lastCursorMoveToSelect', id: '_lastCursorMoveToSelect',
precondition: null precondition: undefined
}); });
} }
@@ -835,7 +835,7 @@ export namespace CoreNavigationCommands {
export const CursorHome: CoreEditorCommand = registerEditorCommand(new HomeCommand({ export const CursorHome: CoreEditorCommand = registerEditorCommand(new HomeCommand({
inSelectionMode: false, inSelectionMode: false,
id: 'cursorHome', id: 'cursorHome',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -847,7 +847,7 @@ export namespace CoreNavigationCommands {
export const CursorHomeSelect: CoreEditorCommand = registerEditorCommand(new HomeCommand({ export const CursorHomeSelect: CoreEditorCommand = registerEditorCommand(new HomeCommand({
inSelectionMode: true, inSelectionMode: true,
id: 'cursorHomeSelect', id: 'cursorHomeSelect',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -860,7 +860,7 @@ export namespace CoreNavigationCommands {
constructor() { constructor() {
super({ super({
id: 'cursorLineStart', id: 'cursorLineStart',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -914,7 +914,7 @@ export namespace CoreNavigationCommands {
export const CursorEnd: CoreEditorCommand = registerEditorCommand(new EndCommand({ export const CursorEnd: CoreEditorCommand = registerEditorCommand(new EndCommand({
inSelectionMode: false, inSelectionMode: false,
id: 'cursorEnd', id: 'cursorEnd',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -926,7 +926,7 @@ export namespace CoreNavigationCommands {
export const CursorEndSelect: CoreEditorCommand = registerEditorCommand(new EndCommand({ export const CursorEndSelect: CoreEditorCommand = registerEditorCommand(new EndCommand({
inSelectionMode: true, inSelectionMode: true,
id: 'cursorEndSelect', id: 'cursorEndSelect',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -939,7 +939,7 @@ export namespace CoreNavigationCommands {
constructor() { constructor() {
super({ super({
id: 'cursorLineEnd', id: 'cursorLineEnd',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -994,7 +994,7 @@ export namespace CoreNavigationCommands {
export const CursorTop: CoreEditorCommand = registerEditorCommand(new TopCommand({ export const CursorTop: CoreEditorCommand = registerEditorCommand(new TopCommand({
inSelectionMode: false, inSelectionMode: false,
id: 'cursorTop', id: 'cursorTop',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -1006,7 +1006,7 @@ export namespace CoreNavigationCommands {
export const CursorTopSelect: CoreEditorCommand = registerEditorCommand(new TopCommand({ export const CursorTopSelect: CoreEditorCommand = registerEditorCommand(new TopCommand({
inSelectionMode: true, inSelectionMode: true,
id: 'cursorTopSelect', id: 'cursorTopSelect',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -1038,7 +1038,7 @@ export namespace CoreNavigationCommands {
export const CursorBottom: CoreEditorCommand = registerEditorCommand(new BottomCommand({ export const CursorBottom: CoreEditorCommand = registerEditorCommand(new BottomCommand({
inSelectionMode: false, inSelectionMode: false,
id: 'cursorBottom', id: 'cursorBottom',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -1050,7 +1050,7 @@ export namespace CoreNavigationCommands {
export const CursorBottomSelect: CoreEditorCommand = registerEditorCommand(new BottomCommand({ export const CursorBottomSelect: CoreEditorCommand = registerEditorCommand(new BottomCommand({
inSelectionMode: true, inSelectionMode: true,
id: 'cursorBottomSelect', id: 'cursorBottomSelect',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -1063,7 +1063,7 @@ export namespace CoreNavigationCommands {
constructor() { constructor() {
super({ super({
id: 'editorScroll', id: 'editorScroll',
precondition: null, precondition: undefined,
description: EditorScroll_.description description: EditorScroll_.description
}); });
} }
@@ -1134,7 +1134,7 @@ export namespace CoreNavigationCommands {
constructor() { constructor() {
super({ super({
id: 'scrollLineUp', id: 'scrollLineUp',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -1159,7 +1159,7 @@ export namespace CoreNavigationCommands {
constructor() { constructor() {
super({ super({
id: 'scrollPageUp', id: 'scrollPageUp',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -1185,7 +1185,7 @@ export namespace CoreNavigationCommands {
constructor() { constructor() {
super({ super({
id: 'scrollLineDown', id: 'scrollLineDown',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -1210,7 +1210,7 @@ export namespace CoreNavigationCommands {
constructor() { constructor() {
super({ super({
id: 'scrollPageDown', id: 'scrollPageDown',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -1257,20 +1257,20 @@ export namespace CoreNavigationCommands {
export const WordSelect: CoreEditorCommand = registerEditorCommand(new WordCommand({ export const WordSelect: CoreEditorCommand = registerEditorCommand(new WordCommand({
inSelectionMode: false, inSelectionMode: false,
id: '_wordSelect', id: '_wordSelect',
precondition: null precondition: undefined
})); }));
export const WordSelectDrag: CoreEditorCommand = registerEditorCommand(new WordCommand({ export const WordSelectDrag: CoreEditorCommand = registerEditorCommand(new WordCommand({
inSelectionMode: true, inSelectionMode: true,
id: '_wordSelectDrag', id: '_wordSelectDrag',
precondition: null precondition: undefined
})); }));
export const LastCursorWordSelect: CoreEditorCommand = registerEditorCommand(new class extends CoreEditorCommand { export const LastCursorWordSelect: CoreEditorCommand = registerEditorCommand(new class extends CoreEditorCommand {
constructor() { constructor() {
super({ super({
id: 'lastCursorWordSelect', id: 'lastCursorWordSelect',
precondition: null precondition: undefined
}); });
} }
@@ -1317,13 +1317,13 @@ export namespace CoreNavigationCommands {
export const LineSelect: CoreEditorCommand = registerEditorCommand(new LineCommand({ export const LineSelect: CoreEditorCommand = registerEditorCommand(new LineCommand({
inSelectionMode: false, inSelectionMode: false,
id: '_lineSelect', id: '_lineSelect',
precondition: null precondition: undefined
})); }));
export const LineSelectDrag: CoreEditorCommand = registerEditorCommand(new LineCommand({ export const LineSelectDrag: CoreEditorCommand = registerEditorCommand(new LineCommand({
inSelectionMode: true, inSelectionMode: true,
id: '_lineSelectDrag', id: '_lineSelectDrag',
precondition: null precondition: undefined
})); }));
class LastCursorLineCommand extends CoreEditorCommand { class LastCursorLineCommand extends CoreEditorCommand {
@@ -1353,20 +1353,20 @@ export namespace CoreNavigationCommands {
export const LastCursorLineSelect: CoreEditorCommand = registerEditorCommand(new LastCursorLineCommand({ export const LastCursorLineSelect: CoreEditorCommand = registerEditorCommand(new LastCursorLineCommand({
inSelectionMode: false, inSelectionMode: false,
id: 'lastCursorLineSelect', id: 'lastCursorLineSelect',
precondition: null precondition: undefined
})); }));
export const LastCursorLineSelectDrag: CoreEditorCommand = registerEditorCommand(new LastCursorLineCommand({ export const LastCursorLineSelectDrag: CoreEditorCommand = registerEditorCommand(new LastCursorLineCommand({
inSelectionMode: true, inSelectionMode: true,
id: 'lastCursorLineSelectDrag', id: 'lastCursorLineSelectDrag',
precondition: null precondition: undefined
})); }));
export const ExpandLineSelection: CoreEditorCommand = registerEditorCommand(new class extends CoreEditorCommand { export const ExpandLineSelection: CoreEditorCommand = registerEditorCommand(new class extends CoreEditorCommand {
constructor() { constructor() {
super({ super({
id: 'expandLineSelection', id: 'expandLineSelection',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
weight: CORE_WEIGHT, weight: CORE_WEIGHT,
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
@@ -1445,7 +1445,7 @@ export namespace CoreNavigationCommands {
constructor() { constructor() {
super({ super({
id: 'revealLine', id: 'revealLine',
precondition: null, precondition: undefined,
description: RevealLine_.description description: RevealLine_.description
}); });
} }
@@ -1493,7 +1493,7 @@ export namespace CoreNavigationCommands {
constructor() { constructor() {
super({ super({
id: 'selectAll', id: 'selectAll',
precondition: null precondition: undefined
}); });
} }
@@ -1513,7 +1513,7 @@ export namespace CoreNavigationCommands {
constructor() { constructor() {
super({ super({
id: 'setSelection', id: 'setSelection',
precondition: null precondition: undefined
}); });
} }
@@ -1728,7 +1728,7 @@ class EditorHandlerCommand extends Command {
constructor(id: string, handlerId: string, description?: ICommandHandlerDescription) { constructor(id: string, handlerId: string, description?: ICommandHandlerDescription) {
super({ super({
id: id, id: id,
precondition: null, precondition: undefined,
description: description description: description
}); });
this._handlerId = handlerId; this._handlerId = handlerId;

View File

@@ -40,17 +40,17 @@ export interface ICommandMenubarOptions {
} }
export interface ICommandOptions { export interface ICommandOptions {
id: string; id: string;
precondition: ContextKeyExpr | null; precondition: ContextKeyExpr | undefined;
kbOpts?: ICommandKeybindingsOptions | null; kbOpts?: ICommandKeybindingsOptions;
description?: ICommandHandlerDescription; description?: ICommandHandlerDescription;
menubarOpts?: ICommandMenubarOptions; menubarOpts?: ICommandMenubarOptions;
} }
export abstract class Command { export abstract class Command {
public readonly id: string; public readonly id: string;
public readonly precondition: ContextKeyExpr | null; public readonly precondition: ContextKeyExpr | undefined;
private readonly _kbOpts: ICommandKeybindingsOptions | null | undefined; private readonly _kbOpts: ICommandKeybindingsOptions | undefined;
private readonly _menubarOpts: ICommandMenubarOptions | null | undefined; private readonly _menubarOpts: ICommandMenubarOptions | undefined;
private readonly _description: ICommandHandlerDescription | null | undefined; private readonly _description: ICommandHandlerDescription | undefined;
constructor(opts: ICommandOptions) { constructor(opts: ICommandOptions) {
this.id = opts.id; this.id = opts.id;

View File

@@ -19,14 +19,11 @@ export function getIconClasses(modelService: IModelService, modeService: IModeSe
// Get the path and name of the resource. For data-URIs, we need to parse specially // Get the path and name of the resource. For data-URIs, we need to parse specially
let name: string | undefined; let name: string | undefined;
let path: string | undefined;
if (resource.scheme === Schemas.data) { if (resource.scheme === Schemas.data) {
const metadata = DataUri.parseMetaData(resource); const metadata = DataUri.parseMetaData(resource);
name = metadata.get(DataUri.META_DATA_LABEL); name = metadata.get(DataUri.META_DATA_LABEL);
path = name;
} else { } else {
name = cssEscape(basenameOrAuthority(resource).toLowerCase()); name = cssEscape(basenameOrAuthority(resource).toLowerCase());
path = resource.path.toLowerCase();
} }
// Folders // Folders
@@ -47,46 +44,60 @@ export function getIconClasses(modelService: IModelService, modeService: IModeSe
classes.push(`ext-file-icon`); // extra segment to increase file-ext score classes.push(`ext-file-icon`); // extra segment to increase file-ext score
} }
// Configured Language // Detected Mode
let configuredLangId: string | null = getConfiguredLangId(modelService, modeService, resource); const detectedModeId = detectModeId(modelService, modeService, resource);
configuredLangId = configuredLangId || (path ? modeService.getModeIdByFilepathOrFirstLine(path) : null); if (detectedModeId) {
if (configuredLangId) { classes.push(`${cssEscape(detectedModeId)}-lang-file-icon`);
classes.push(`${cssEscape(configuredLangId)}-lang-file-icon`);
} }
} }
} }
return classes; return classes;
} }
export function getConfiguredLangId(modelService: IModelService, modeService: IModeService, resource: uri): string | null { export function detectModeId(modelService: IModelService, modeService: IModeService, resource: uri): string | null {
let configuredLangId: string | null = null; if (!resource) {
if (resource) { return null; // we need a resource at least
let modeId: string | null = null; }
// Data URI: check for encoded metadata let modeId: string | null = null;
if (resource.scheme === Schemas.data) {
const metadata = DataUri.parseMetaData(resource);
const mime = metadata.get(DataUri.META_DATA_MIME);
if (mime) { // Data URI: check for encoded metadata
modeId = modeService.getModeId(mime); if (resource.scheme === Schemas.data) {
} const metadata = DataUri.parseMetaData(resource);
} const mime = metadata.get(DataUri.META_DATA_MIME);
// Any other URI: check for model if existing if (mime) {
else { modeId = modeService.getModeId(mime);
const model = modelService.getModel(resource);
if (model) {
modeId = model.getLanguageIdentifier().language;
}
}
if (modeId && modeId !== PLAINTEXT_MODE_ID) {
configuredLangId = modeId; // only take if the mode is specific (aka no just plain text)
} }
} }
return configuredLangId; // Any other URI: check for model if existing
else {
const model = modelService.getModel(resource);
if (model) {
modeId = model.getModeId();
}
}
// only take if the mode is specific (aka no just plain text)
if (modeId && modeId !== PLAINTEXT_MODE_ID) {
return modeId;
}
// otherwise fallback to path based detection
let path: string | undefined;
if (resource.scheme === Schemas.data) {
const metadata = DataUri.parseMetaData(resource);
path = metadata.get(DataUri.META_DATA_LABEL);
} else {
path = resource.path.toLowerCase();
}
if (path) {
return modeService.getModeIdByFilepathOrFirstLine(path);
}
return null; // finally - we do not know the mode id
} }
export function cssEscape(val: string): string { export function cssEscape(val: string): string {

View File

@@ -5,7 +5,7 @@
import { IDisposable, IReference } from 'vs/base/common/lifecycle'; import { IDisposable, IReference } from 'vs/base/common/lifecycle';
import { URI } from 'vs/base/common/uri'; import { URI } from 'vs/base/common/uri';
import { ITextModel } from 'vs/editor/common/model'; import { ITextModel, ITextSnapshot } from 'vs/editor/common/model';
import { IEditorModel } from 'vs/platform/editor/common/editor'; import { IEditorModel } from 'vs/platform/editor/common/editor';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
@@ -46,6 +46,12 @@ export interface ITextEditorModel extends IEditorModel {
*/ */
readonly textEditorModel: ITextModel | null; readonly textEditorModel: ITextModel | null;
/**
* Creates a snapshot of the model's contents.
*/
createSnapshot(this: IResolvedTextEditorModel): ITextSnapshot;
createSnapshot(this: ITextEditorModel): ITextSnapshot | null;
isReadonly(): boolean; isReadonly(): boolean;
} }

View File

@@ -31,7 +31,7 @@ class JumpToBracketAction extends EditorAction {
id: 'editor.action.jumpToBracket', id: 'editor.action.jumpToBracket',
label: nls.localize('smartSelect.jumpBracket', "Go to Bracket"), label: nls.localize('smartSelect.jumpBracket', "Go to Bracket"),
alias: 'Go to Bracket', alias: 'Go to Bracket',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus, kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_BACKSLASH, primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_BACKSLASH,
@@ -55,7 +55,7 @@ class SelectToBracketAction extends EditorAction {
id: 'editor.action.selectToBracket', id: 'editor.action.selectToBracket',
label: nls.localize('smartSelect.selectToBracket', "Select to Bracket"), label: nls.localize('smartSelect.selectToBracket', "Select to Bracket"),
alias: 'Select to Bracket', alias: 'Select to Bracket',
precondition: null precondition: undefined
}); });
} }

View File

@@ -59,7 +59,7 @@ abstract class ExecCommandAction extends EditorAction {
class ExecCommandCutAction extends ExecCommandAction { class ExecCommandCutAction extends ExecCommandAction {
constructor() { constructor() {
let kbOpts: ICommandKeybindingsOptions | null = { let kbOpts: ICommandKeybindingsOptions | undefined = {
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_X, primary: KeyMod.CtrlCmd | KeyCode.KEY_X,
win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_X, secondary: [KeyMod.Shift | KeyCode.Delete] }, win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_X, secondary: [KeyMod.Shift | KeyCode.Delete] },
@@ -68,7 +68,7 @@ class ExecCommandCutAction extends ExecCommandAction {
// Do not bind cut keybindings in the browser, // Do not bind cut keybindings in the browser,
// since browsers do that for us and it avoids security prompts // since browsers do that for us and it avoids security prompts
if (!platform.isNative) { if (!platform.isNative) {
kbOpts = null; kbOpts = undefined;
} }
super('cut', { super('cut', {
id: 'editor.action.clipboardCutAction', id: 'editor.action.clipboardCutAction',
@@ -107,7 +107,7 @@ class ExecCommandCutAction extends ExecCommandAction {
class ExecCommandCopyAction extends ExecCommandAction { class ExecCommandCopyAction extends ExecCommandAction {
constructor() { constructor() {
let kbOpts: ICommandKeybindingsOptions | null = { let kbOpts: ICommandKeybindingsOptions | undefined = {
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_C, primary: KeyMod.CtrlCmd | KeyCode.KEY_C,
win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_C, secondary: [KeyMod.CtrlCmd | KeyCode.Insert] }, win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_C, secondary: [KeyMod.CtrlCmd | KeyCode.Insert] },
@@ -116,14 +116,14 @@ class ExecCommandCopyAction extends ExecCommandAction {
// Do not bind copy keybindings in the browser, // Do not bind copy keybindings in the browser,
// since browsers do that for us and it avoids security prompts // since browsers do that for us and it avoids security prompts
if (!platform.isNative) { if (!platform.isNative) {
kbOpts = null; kbOpts = undefined;
} }
super('copy', { super('copy', {
id: 'editor.action.clipboardCopyAction', id: 'editor.action.clipboardCopyAction',
label: nls.localize('actions.clipboard.copyLabel', "Copy"), label: nls.localize('actions.clipboard.copyLabel', "Copy"),
alias: 'Copy', alias: 'Copy',
precondition: null, precondition: undefined,
kbOpts: kbOpts, kbOpts: kbOpts,
menuOpts: { menuOpts: {
group: CLIPBOARD_CONTEXT_MENU_GROUP, group: CLIPBOARD_CONTEXT_MENU_GROUP,
@@ -162,7 +162,7 @@ class ExecCommandCopyAction extends ExecCommandAction {
class ExecCommandPasteAction extends ExecCommandAction { class ExecCommandPasteAction extends ExecCommandAction {
constructor() { constructor() {
let kbOpts: ICommandKeybindingsOptions | null = { let kbOpts: ICommandKeybindingsOptions | undefined = {
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_V, primary: KeyMod.CtrlCmd | KeyCode.KEY_V,
win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_V, secondary: [KeyMod.Shift | KeyCode.Insert] }, win: { primary: KeyMod.CtrlCmd | KeyCode.KEY_V, secondary: [KeyMod.Shift | KeyCode.Insert] },
@@ -171,7 +171,7 @@ class ExecCommandPasteAction extends ExecCommandAction {
// Do not bind paste keybindings in the browser, // Do not bind paste keybindings in the browser,
// since browsers do that for us and it avoids security prompts // since browsers do that for us and it avoids security prompts
if (!platform.isNative) { if (!platform.isNative) {
kbOpts = null; kbOpts = undefined;
} }
super('paste', { super('paste', {
@@ -201,7 +201,7 @@ class ExecCommandCopyWithSyntaxHighlightingAction extends ExecCommandAction {
id: 'editor.action.clipboardCopyWithSyntaxHighlightingAction', id: 'editor.action.clipboardCopyWithSyntaxHighlightingAction',
label: nls.localize('actions.clipboard.copyWithSyntaxHighlightingLabel', "Copy With Syntax Highlighting"), label: nls.localize('actions.clipboard.copyWithSyntaxHighlightingLabel', "Copy With Syntax Highlighting"),
alias: 'Copy With Syntax Highlighting', alias: 'Copy With Syntax Highlighting',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
primary: 0, primary: 0,

View File

@@ -34,8 +34,8 @@ export class CodeActionSet {
public readonly actions: readonly CodeAction[]; public readonly actions: readonly CodeAction[];
public constructor(actions: CodeAction[]) { public constructor(actions: readonly CodeAction[]) {
this.actions = mergeSort(actions, CodeActionSet.codeActionsComparator); this.actions = mergeSort([...actions], CodeActionSet.codeActionsComparator);
} }
public get hasAutoFix() { public get hasAutoFix() {

View File

@@ -176,6 +176,7 @@ function showCodeActionsForEditorSelection(
return; return;
} }
MessageController.get(editor).closeMessage();
const pos = editor.getPosition(); const pos = editor.getPosition();
controller.triggerFromEditorSelection(filter, autoApply).then(codeActions => { controller.triggerFromEditorSelection(filter, autoApply).then(codeActions => {
if (!codeActions || !codeActions.actions.length) { if (!codeActions || !codeActions.actions.length) {

View File

@@ -20,8 +20,12 @@ export class CodeActionKind {
public readonly value: string public readonly value: string
) { } ) { }
public equals(other: CodeActionKind): boolean {
return this.value === other.value;
}
public contains(other: CodeActionKind): boolean { public contains(other: CodeActionKind): boolean {
return this.value === other.value || startsWith(other.value, this.value + CodeActionKind.sep); return this.equals(other) || startsWith(other.value, this.value + CodeActionKind.sep);
} }
public intersects(other: CodeActionKind): boolean { public intersects(other: CodeActionKind): boolean {

View File

@@ -76,9 +76,9 @@ export class ColorDetector implements IEditorContribution {
} }
const languageId = model.getLanguageIdentifier(); const languageId = model.getLanguageIdentifier();
// handle deprecated settings. [languageId].colorDecorators.enable // handle deprecated settings. [languageId].colorDecorators.enable
let deprecatedConfig = this._configurationService.getValue(languageId.language); const deprecatedConfig = this._configurationService.getValue<{}>(languageId.language);
if (deprecatedConfig) { if (deprecatedConfig) {
let colorDecorators = deprecatedConfig['colorDecorators']; // deprecatedConfig.valueOf('.colorDecorators.enable'); const colorDecorators = deprecatedConfig['colorDecorators']; // deprecatedConfig.valueOf('.colorDecorators.enable');
if (colorDecorators && colorDecorators['enable'] !== undefined && !colorDecorators['enable']) { if (colorDecorators && colorDecorators['enable'] !== undefined && !colorDecorators['enable']) {
return colorDecorators['enable']; return colorDecorators['enable'];
} }

View File

@@ -6,7 +6,7 @@
import * as nls from 'vs/nls'; import * as nls from 'vs/nls';
import * as dom from 'vs/base/browser/dom'; import * as dom from 'vs/base/browser/dom';
import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent'; import { IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { ActionItem, Separator } from 'vs/base/browser/ui/actionbar/actionbar'; import { ActionViewItem, Separator } from 'vs/base/browser/ui/actionbar/actionbar';
import { IAnchor } from 'vs/base/browser/ui/contextview/contextview'; import { IAnchor } from 'vs/base/browser/ui/contextview/contextview';
import { IAction } from 'vs/base/common/actions'; import { IAction } from 'vs/base/common/actions';
import { KeyCode, KeyMod, ResolvedKeybinding } from 'vs/base/common/keyCodes'; import { KeyCode, KeyMod, ResolvedKeybinding } from 'vs/base/common/keyCodes';
@@ -176,18 +176,18 @@ export class ContextMenuController implements IEditorContribution {
getActions: () => actions, getActions: () => actions,
getActionItem: (action) => { getActionViewItem: (action) => {
const keybinding = this._keybindingFor(action); const keybinding = this._keybindingFor(action);
if (keybinding) { if (keybinding) {
return new ActionItem(action, action, { label: true, keybinding: keybinding.getLabel(), isMenu: true }); return new ActionViewItem(action, action, { label: true, keybinding: keybinding.getLabel(), isMenu: true });
} }
const customActionItem = <any>action; const customActionViewItem = <any>action;
if (typeof customActionItem.getActionItem === 'function') { if (typeof customActionViewItem.getActionViewItem === 'function') {
return customActionItem.getActionItem(); return customActionViewItem.getActionViewItem();
} }
return new ActionItem(action, action, { icon: true, label: true, isMenu: true }); return new ActionViewItem(action, action, { icon: true, label: true, isMenu: true });
}, },
getKeyBinding: (action): ResolvedKeybinding | undefined => { getKeyBinding: (action): ResolvedKeybinding | undefined => {
@@ -228,7 +228,7 @@ class ShowContextMenu extends EditorAction {
id: 'editor.action.showContextMenu', id: 'editor.action.showContextMenu',
label: nls.localize('action.showContextMenu.label', "Show Editor Context Menu"), label: nls.localize('action.showContextMenu.label', "Show Editor Context Menu"),
alias: 'Show Editor Context Menu', alias: 'Show Editor Context Menu',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
primary: KeyMod.Shift | KeyCode.F10, primary: KeyMod.Shift | KeyCode.F10,

View File

@@ -119,7 +119,7 @@ export class CursorUndo extends EditorAction {
id: 'cursorUndo', id: 'cursorUndo',
label: nls.localize('cursor.undo', "Soft Undo"), label: nls.localize('cursor.undo', "Soft Undo"),
alias: 'Soft Undo', alias: 'Soft Undo',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.textInputFocus, kbExpr: EditorContextKeys.textInputFocus,
primary: KeyMod.CtrlCmd | KeyCode.KEY_U, primary: KeyMod.CtrlCmd | KeyCode.KEY_U,

View File

@@ -422,7 +422,7 @@ export class StartFindAction extends EditorAction {
id: FIND_IDS.StartFindAction, id: FIND_IDS.StartFindAction,
label: nls.localize('startFindAction', "Find"), label: nls.localize('startFindAction', "Find"),
alias: 'Find', alias: 'Find',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
kbExpr: null, kbExpr: null,
primary: KeyMod.CtrlCmd | KeyCode.KEY_F, primary: KeyMod.CtrlCmd | KeyCode.KEY_F,
@@ -459,7 +459,7 @@ export class StartFindWithSelectionAction extends EditorAction {
id: FIND_IDS.StartFindWithSelection, id: FIND_IDS.StartFindWithSelection,
label: nls.localize('startFindWithSelectionAction', "Find With Selection"), label: nls.localize('startFindWithSelectionAction', "Find With Selection"),
alias: 'Find With Selection', alias: 'Find With Selection',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
kbExpr: null, kbExpr: null,
primary: 0, primary: 0,
@@ -513,7 +513,7 @@ export class NextMatchFindAction extends MatchFindAction {
id: FIND_IDS.NextMatchFindAction, id: FIND_IDS.NextMatchFindAction,
label: nls.localize('findNextMatchAction', "Find Next"), label: nls.localize('findNextMatchAction', "Find Next"),
alias: 'Find Next', alias: 'Find Next',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.focus, kbExpr: EditorContextKeys.focus,
primary: KeyCode.F3, primary: KeyCode.F3,
@@ -535,7 +535,7 @@ export class PreviousMatchFindAction extends MatchFindAction {
id: FIND_IDS.PreviousMatchFindAction, id: FIND_IDS.PreviousMatchFindAction,
label: nls.localize('findPreviousMatchAction', "Find Previous"), label: nls.localize('findPreviousMatchAction', "Find Previous"),
alias: 'Find Previous', alias: 'Find Previous',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.focus, kbExpr: EditorContextKeys.focus,
primary: KeyMod.Shift | KeyCode.F3, primary: KeyMod.Shift | KeyCode.F3,
@@ -583,7 +583,7 @@ export class NextSelectionMatchFindAction extends SelectionMatchFindAction {
id: FIND_IDS.NextSelectionMatchFindAction, id: FIND_IDS.NextSelectionMatchFindAction,
label: nls.localize('nextSelectionMatchFindAction', "Find Next Selection"), label: nls.localize('nextSelectionMatchFindAction', "Find Next Selection"),
alias: 'Find Next Selection', alias: 'Find Next Selection',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.focus, kbExpr: EditorContextKeys.focus,
primary: KeyMod.CtrlCmd | KeyCode.F3, primary: KeyMod.CtrlCmd | KeyCode.F3,
@@ -604,7 +604,7 @@ export class PreviousSelectionMatchFindAction extends SelectionMatchFindAction {
id: FIND_IDS.PreviousSelectionMatchFindAction, id: FIND_IDS.PreviousSelectionMatchFindAction,
label: nls.localize('previousSelectionMatchFindAction', "Find Previous Selection"), label: nls.localize('previousSelectionMatchFindAction', "Find Previous Selection"),
alias: 'Find Previous Selection', alias: 'Find Previous Selection',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.focus, kbExpr: EditorContextKeys.focus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.F3, primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.F3,
@@ -625,7 +625,7 @@ export class StartFindReplaceAction extends EditorAction {
id: FIND_IDS.StartFindReplaceAction, id: FIND_IDS.StartFindReplaceAction,
label: nls.localize('startReplace', "Replace"), label: nls.localize('startReplace', "Replace"),
alias: 'Replace', alias: 'Replace',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
kbExpr: null, kbExpr: null,
primary: KeyMod.CtrlCmd | KeyCode.KEY_H, primary: KeyMod.CtrlCmd | KeyCode.KEY_H,
@@ -704,7 +704,7 @@ registerEditorCommand(new FindCommand({
registerEditorCommand(new FindCommand({ registerEditorCommand(new FindCommand({
id: FIND_IDS.ToggleCaseSensitiveCommand, id: FIND_IDS.ToggleCaseSensitiveCommand,
precondition: null, precondition: undefined,
handler: x => x.toggleCaseSensitive(), handler: x => x.toggleCaseSensitive(),
kbOpts: { kbOpts: {
weight: KeybindingWeight.EditorContrib + 5, weight: KeybindingWeight.EditorContrib + 5,
@@ -718,7 +718,7 @@ registerEditorCommand(new FindCommand({
registerEditorCommand(new FindCommand({ registerEditorCommand(new FindCommand({
id: FIND_IDS.ToggleWholeWordCommand, id: FIND_IDS.ToggleWholeWordCommand,
precondition: null, precondition: undefined,
handler: x => x.toggleWholeWords(), handler: x => x.toggleWholeWords(),
kbOpts: { kbOpts: {
weight: KeybindingWeight.EditorContrib + 5, weight: KeybindingWeight.EditorContrib + 5,
@@ -732,7 +732,7 @@ registerEditorCommand(new FindCommand({
registerEditorCommand(new FindCommand({ registerEditorCommand(new FindCommand({
id: FIND_IDS.ToggleRegexCommand, id: FIND_IDS.ToggleRegexCommand,
precondition: null, precondition: undefined,
handler: x => x.toggleRegex(), handler: x => x.toggleRegex(),
kbOpts: { kbOpts: {
weight: KeybindingWeight.EditorContrib + 5, weight: KeybindingWeight.EditorContrib + 5,
@@ -746,7 +746,7 @@ registerEditorCommand(new FindCommand({
registerEditorCommand(new FindCommand({ registerEditorCommand(new FindCommand({
id: FIND_IDS.ToggleSearchScopeCommand, id: FIND_IDS.ToggleSearchScopeCommand,
precondition: null, precondition: undefined,
handler: x => x.toggleSearchScope(), handler: x => x.toggleSearchScope(),
kbOpts: { kbOpts: {
weight: KeybindingWeight.EditorContrib + 5, weight: KeybindingWeight.EditorContrib + 5,

View File

@@ -503,7 +503,7 @@ class UnfoldAction extends FoldingAction<FoldingArguments> {
id: 'editor.unfold', id: 'editor.unfold',
label: nls.localize('unfoldAction.label', "Unfold"), label: nls.localize('unfoldAction.label', "Unfold"),
alias: 'Unfold', alias: 'Unfold',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus, kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_CLOSE_SQUARE_BRACKET, primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_CLOSE_SQUARE_BRACKET,
@@ -567,7 +567,7 @@ class UnFoldRecursivelyAction extends FoldingAction<void> {
id: 'editor.unfoldRecursively', id: 'editor.unfoldRecursively',
label: nls.localize('unFoldRecursivelyAction.label', "Unfold Recursively"), label: nls.localize('unFoldRecursivelyAction.label', "Unfold Recursively"),
alias: 'Unfold Recursively', alias: 'Unfold Recursively',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus, kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.US_CLOSE_SQUARE_BRACKET), primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.US_CLOSE_SQUARE_BRACKET),
@@ -588,7 +588,7 @@ class FoldAction extends FoldingAction<FoldingArguments> {
id: 'editor.fold', id: 'editor.fold',
label: nls.localize('foldAction.label', "Fold"), label: nls.localize('foldAction.label', "Fold"),
alias: 'Fold', alias: 'Fold',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus, kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_OPEN_SQUARE_BRACKET, primary: KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.US_OPEN_SQUARE_BRACKET,
@@ -652,7 +652,7 @@ class FoldRecursivelyAction extends FoldingAction<void> {
id: 'editor.foldRecursively', id: 'editor.foldRecursively',
label: nls.localize('foldRecursivelyAction.label', "Fold Recursively"), label: nls.localize('foldRecursivelyAction.label', "Fold Recursively"),
alias: 'Fold Recursively', alias: 'Fold Recursively',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus, kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.US_OPEN_SQUARE_BRACKET), primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.US_OPEN_SQUARE_BRACKET),
@@ -674,7 +674,7 @@ class FoldAllBlockCommentsAction extends FoldingAction<void> {
id: 'editor.foldAllBlockComments', id: 'editor.foldAllBlockComments',
label: nls.localize('foldAllBlockComments.label', "Fold All Block Comments"), label: nls.localize('foldAllBlockComments.label', "Fold All Block Comments"),
alias: 'Fold All Block Comments', alias: 'Fold All Block Comments',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus, kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.US_SLASH), primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.US_SLASH),
@@ -707,7 +707,7 @@ class FoldAllRegionsAction extends FoldingAction<void> {
id: 'editor.foldAllMarkerRegions', id: 'editor.foldAllMarkerRegions',
label: nls.localize('foldAllMarkerRegions.label', "Fold All Regions"), label: nls.localize('foldAllMarkerRegions.label', "Fold All Regions"),
alias: 'Fold All Regions', alias: 'Fold All Regions',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus, kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_8), primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_8),
@@ -740,7 +740,7 @@ class UnfoldAllRegionsAction extends FoldingAction<void> {
id: 'editor.unfoldAllMarkerRegions', id: 'editor.unfoldAllMarkerRegions',
label: nls.localize('unfoldAllMarkerRegions.label', "Unfold All Regions"), label: nls.localize('unfoldAllMarkerRegions.label', "Unfold All Regions"),
alias: 'Unfold All Regions', alias: 'Unfold All Regions',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus, kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_9), primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_9),
@@ -773,7 +773,7 @@ class FoldAllAction extends FoldingAction<void> {
id: 'editor.foldAll', id: 'editor.foldAll',
label: nls.localize('foldAllAction.label', "Fold All"), label: nls.localize('foldAllAction.label', "Fold All"),
alias: 'Fold All', alias: 'Fold All',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus, kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_0), primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_0),
@@ -794,7 +794,7 @@ class UnfoldAllAction extends FoldingAction<void> {
id: 'editor.unfoldAll', id: 'editor.unfoldAll',
label: nls.localize('unfoldAllAction.label', "Unfold All"), label: nls.localize('unfoldAllAction.label', "Unfold All"),
alias: 'Unfold All', alias: 'Unfold All',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus, kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_J), primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_J),
@@ -838,7 +838,7 @@ for (let i = 1; i <= 7; i++) {
id: FoldLevelAction.ID(i), id: FoldLevelAction.ID(i),
label: nls.localize('foldLevelAction.label', "Fold Level {0}", i), label: nls.localize('foldLevelAction.label', "Fold Level {0}", i),
alias: `Fold Level ${i}`, alias: `Fold Level ${i}`,
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus, kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | (KeyCode.KEY_0 + i)), primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | (KeyCode.KEY_0 + i)),

View File

@@ -15,7 +15,7 @@ class EditorFontZoomIn extends EditorAction {
id: 'editor.action.fontZoomIn', id: 'editor.action.fontZoomIn',
label: nls.localize('EditorFontZoomIn.label', "Editor Font Zoom In"), label: nls.localize('EditorFontZoomIn.label', "Editor Font Zoom In"),
alias: 'Editor Font Zoom In', alias: 'Editor Font Zoom In',
precondition: null precondition: undefined
}); });
} }
@@ -31,7 +31,7 @@ class EditorFontZoomOut extends EditorAction {
id: 'editor.action.fontZoomOut', id: 'editor.action.fontZoomOut',
label: nls.localize('EditorFontZoomOut.label', "Editor Font Zoom Out"), label: nls.localize('EditorFontZoomOut.label', "Editor Font Zoom Out"),
alias: 'Editor Font Zoom Out', alias: 'Editor Font Zoom Out',
precondition: null precondition: undefined
}); });
} }
@@ -47,7 +47,7 @@ class EditorFontZoomReset extends EditorAction {
id: 'editor.action.fontZoomReset', id: 'editor.action.fontZoomReset',
label: nls.localize('EditorFontZoomReset.label', "Editor Font Zoom Reset"), label: nls.localize('EditorFontZoomReset.label', "Editor Font Zoom Reset"),
alias: 'Editor Font Zoom Reset', alias: 'Editor Font Zoom Reset',
precondition: null precondition: undefined
}); });
} }

View File

@@ -294,7 +294,7 @@ class GotoDefinitionWithMouseEditorContribution implements editorCommon.IEditorC
private gotoDefinition(target: IMouseTarget, sideBySide: boolean): Promise<any> { private gotoDefinition(target: IMouseTarget, sideBySide: boolean): Promise<any> {
this.editor.setPosition(target.position!); this.editor.setPosition(target.position!);
const action = new DefinitionAction(new DefinitionActionConfig(sideBySide, false, true, false), { alias: '', label: '', id: '', precondition: null }); const action = new DefinitionAction(new DefinitionActionConfig(sideBySide, false, true, false), { alias: '', label: '', id: '', precondition: undefined });
return this.editor.invokeWithinContext(accessor => action.run(accessor, this.editor)); return this.editor.invokeWithinContext(accessor => action.run(accessor, this.editor));
} }

View File

@@ -251,7 +251,7 @@ class ShowHoverAction extends EditorAction {
] ]
}, "Show Hover"), }, "Show Hover"),
alias: 'Show Hover', alias: 'Show Hover',
precondition: null, precondition: undefined,
kbOpts: { kbOpts: {
kbExpr: EditorContextKeys.editorTextFocus, kbExpr: EditorContextKeys.editorTextFocus,
primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_I), primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_I),

View File

@@ -40,7 +40,6 @@ import { applyCodeAction, QuickFixAction } from 'vs/editor/contrib/codeAction/co
import { Action } from 'vs/base/common/actions'; import { Action } from 'vs/base/common/actions';
import { CodeActionKind } from 'vs/editor/contrib/codeAction/codeActionTrigger'; import { CodeActionKind } from 'vs/editor/contrib/codeAction/codeActionTrigger';
import { IModeService } from 'vs/editor/common/services/modeService'; import { IModeService } from 'vs/editor/common/services/modeService';
import { withNullAsUndefined } from 'vs/base/common/types';
import { IIdentifiedSingleEditOperation } from 'vs/editor/common/model'; import { IIdentifiedSingleEditOperation } from 'vs/editor/common/model';
const $ = dom.$; const $ = dom.$;
@@ -68,14 +67,13 @@ class ModesContentComputer implements IHoverComputer<HoverPart[]> {
private readonly _editor: ICodeEditor; private readonly _editor: ICodeEditor;
private _result: HoverPart[]; private _result: HoverPart[];
private _range: Range | null; private _range?: Range;
constructor( constructor(
editor: ICodeEditor, editor: ICodeEditor,
private readonly _markerDecorationsService: IMarkerDecorationsService private readonly _markerDecorationsService: IMarkerDecorationsService
) { ) {
this._editor = editor; this._editor = editor;
this._range = null;
} }
setRange(range: Range): void { setRange(range: Range): void {
@@ -183,7 +181,7 @@ class ModesContentComputer implements IHoverComputer<HoverPart[]> {
private _getLoadingMessage(): HoverPart { private _getLoadingMessage(): HoverPart {
return { return {
range: withNullAsUndefined(this._range), range: this._range,
contents: [new MarkdownString().appendText(nls.localize('modesContentHover.loading', "Loading..."))] contents: [new MarkdownString().appendText(nls.localize('modesContentHover.loading', "Loading..."))]
}; };
} }

View File

@@ -253,7 +253,7 @@ export class IndentUsingTabs extends ChangeIndentationSizeAction {
id: IndentUsingTabs.ID, id: IndentUsingTabs.ID,
label: nls.localize('indentUsingTabs', "Indent Using Tabs"), label: nls.localize('indentUsingTabs', "Indent Using Tabs"),
alias: 'Indent Using Tabs', alias: 'Indent Using Tabs',
precondition: null precondition: undefined
}); });
} }
} }
@@ -267,7 +267,7 @@ export class IndentUsingSpaces extends ChangeIndentationSizeAction {
id: IndentUsingSpaces.ID, id: IndentUsingSpaces.ID,
label: nls.localize('indentUsingSpaces', "Indent Using Spaces"), label: nls.localize('indentUsingSpaces', "Indent Using Spaces"),
alias: 'Indent Using Spaces', alias: 'Indent Using Spaces',
precondition: null precondition: undefined
}); });
} }
} }
@@ -281,7 +281,7 @@ export class DetectIndentation extends EditorAction {
id: DetectIndentation.ID, id: DetectIndentation.ID,
label: nls.localize('detectIndentation', "Detect Indentation from Content"), label: nls.localize('detectIndentation', "Detect Indentation from Content"),
alias: 'Detect Indentation from Content', alias: 'Detect Indentation from Content',
precondition: null precondition: undefined
}); });
} }

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