Merge from vscode 817eb6b0c720a4ecbc13c020afbbebfed667aa09 (#7356)

This commit is contained in:
Anthony Dresser
2019-09-24 21:36:17 -07:00
committed by GitHub
parent a29ae4d3b9
commit 6a6048d40f
541 changed files with 7045 additions and 7287 deletions

View File

@@ -61,4 +61,4 @@
"msjsdiag.debugger-for-chrome": "workspace"
},
"files.insertFinalNewline": true
}
}

View File

@@ -41,13 +41,7 @@ var editorEntryPoints = [
];
var editorResources = [
'out-build/vs/{base,editor}/**/*.{svg,png}',
'!out-build/vs/base/browser/ui/splitview/**/*',
'!out-build/vs/base/browser/ui/toolbar/**/*',
'!out-build/vs/base/browser/ui/octiconLabel/**/*',
'!out-build/vs/base/browser/ui/codiconLabel/**/*',
'!out-build/vs/workbench/**',
'!**/test/**'
'out-editor-build/vs/base/browser/ui/codiconLabel/**/*.ttf'
];
var BUNDLED_FILE_HEADER = [
@@ -92,7 +86,6 @@ const extractEditorSrcTask = task.define('extract-editor-src', () => {
],
redirects: {
'vs/base/browser/ui/octiconLabel/octiconLabel': 'vs/base/browser/ui/octiconLabel/octiconLabel.mock',
'vs/base/browser/ui/codiconLabel/codiconLabel': 'vs/base/browser/ui/codiconLabel/codiconLabel.mock',
},
shakeLevel: 2, // 0-Files, 1-InnerFile, 2-ClassMembers
importIgnorePattern: /(^vs\/css!)|(promise-polyfill\/polyfill)/,

View File

@@ -130,7 +130,7 @@ function createESMSourcesAndResources2(options) {
write(getDestAbsoluteFilePath(file), JSON.stringify(tsConfig, null, '\t'));
continue;
}
if (/\.d\.ts$/.test(file) || /\.css$/.test(file) || /\.js$/.test(file)) {
if (/\.d\.ts$/.test(file) || /\.css$/.test(file) || /\.js$/.test(file) || /\.ttf$/.test(file)) {
// Transport the files directly
write(getDestAbsoluteFilePath(file), fs.readFileSync(path.join(SRC_FOLDER, file)));
continue;
@@ -250,35 +250,37 @@ function transportCSS(module, enqueue, write) {
const filename = path.join(SRC_DIR, module);
const fileContents = fs.readFileSync(filename).toString();
const inlineResources = 'base64'; // see https://github.com/Microsoft/monaco-editor/issues/148
const inlineResourcesLimit = 300000; //3000; // see https://github.com/Microsoft/monaco-editor/issues/336
const newContents = _rewriteOrInlineUrls(fileContents, inlineResources === 'base64', inlineResourcesLimit);
const newContents = _rewriteOrInlineUrls(fileContents, inlineResources === 'base64');
write(module, newContents);
return true;
function _rewriteOrInlineUrls(contents, forceBase64, inlineByteLimit) {
function _rewriteOrInlineUrls(contents, forceBase64) {
return _replaceURL(contents, (url) => {
let imagePath = path.join(path.dirname(module), url);
let fileContents = fs.readFileSync(path.join(SRC_DIR, imagePath));
if (fileContents.length < inlineByteLimit) {
const MIME = /\.svg$/.test(url) ? 'image/svg+xml' : 'image/png';
let DATA = ';base64,' + fileContents.toString('base64');
if (!forceBase64 && /\.svg$/.test(url)) {
// .svg => url encode as explained at https://codepen.io/tigt/post/optimizing-svgs-in-data-uris
let newText = fileContents.toString()
.replace(/"/g, '\'')
.replace(/</g, '%3C')
.replace(/>/g, '%3E')
.replace(/&/g, '%26')
.replace(/#/g, '%23')
.replace(/\s+/g, ' ');
let encodedData = ',' + newText;
if (encodedData.length < DATA.length) {
DATA = encodedData;
}
}
return '"data:' + MIME + DATA + '"';
const fontMatch = url.match(/^(.*).ttf\?(.*)$/);
if (fontMatch) {
const relativeFontPath = `${fontMatch[1]}.ttf`; // trim the query parameter
const fontPath = path.join(path.dirname(module), relativeFontPath);
enqueue(fontPath);
return relativeFontPath;
}
enqueue(imagePath);
return url;
const imagePath = path.join(path.dirname(module), url);
const fileContents = fs.readFileSync(path.join(SRC_DIR, imagePath));
const MIME = /\.svg$/.test(url) ? 'image/svg+xml' : 'image/png';
let DATA = ';base64,' + fileContents.toString('base64');
if (!forceBase64 && /\.svg$/.test(url)) {
// .svg => url encode as explained at https://codepen.io/tigt/post/optimizing-svgs-in-data-uris
let newText = fileContents.toString()
.replace(/"/g, '\'')
.replace(/</g, '%3C')
.replace(/>/g, '%3E')
.replace(/&/g, '%26')
.replace(/#/g, '%23')
.replace(/\s+/g, ' ');
let encodedData = ',' + newText;
if (encodedData.length < DATA.length) {
DATA = encodedData;
}
}
return '"data:' + MIME + DATA + '"';
});
}
function _replaceURL(contents, replacer) {

View File

@@ -154,7 +154,7 @@ export function createESMSourcesAndResources2(options: IOptions2): void {
continue;
}
if (/\.d\.ts$/.test(file) || /\.css$/.test(file) || /\.js$/.test(file)) {
if (/\.d\.ts$/.test(file) || /\.css$/.test(file) || /\.js$/.test(file) || /\.ttf$/.test(file)) {
// Transport the files directly
write(getDestAbsoluteFilePath(file), fs.readFileSync(path.join(SRC_FOLDER, file)));
continue;
@@ -290,40 +290,41 @@ function transportCSS(module: string, enqueue: (module: string) => void, write:
const filename = path.join(SRC_DIR, module);
const fileContents = fs.readFileSync(filename).toString();
const inlineResources = 'base64'; // see https://github.com/Microsoft/monaco-editor/issues/148
const inlineResourcesLimit = 300000;//3000; // see https://github.com/Microsoft/monaco-editor/issues/336
const newContents = _rewriteOrInlineUrls(fileContents, inlineResources === 'base64', inlineResourcesLimit);
const newContents = _rewriteOrInlineUrls(fileContents, inlineResources === 'base64');
write(module, newContents);
return true;
function _rewriteOrInlineUrls(contents: string, forceBase64: boolean, inlineByteLimit: number): string {
function _rewriteOrInlineUrls(contents: string, forceBase64: boolean): string {
return _replaceURL(contents, (url) => {
let imagePath = path.join(path.dirname(module), url);
let fileContents = fs.readFileSync(path.join(SRC_DIR, imagePath));
if (fileContents.length < inlineByteLimit) {
const MIME = /\.svg$/.test(url) ? 'image/svg+xml' : 'image/png';
let DATA = ';base64,' + fileContents.toString('base64');
if (!forceBase64 && /\.svg$/.test(url)) {
// .svg => url encode as explained at https://codepen.io/tigt/post/optimizing-svgs-in-data-uris
let newText = fileContents.toString()
.replace(/"/g, '\'')
.replace(/</g, '%3C')
.replace(/>/g, '%3E')
.replace(/&/g, '%26')
.replace(/#/g, '%23')
.replace(/\s+/g, ' ');
let encodedData = ',' + newText;
if (encodedData.length < DATA.length) {
DATA = encodedData;
}
}
return '"data:' + MIME + DATA + '"';
const fontMatch = url.match(/^(.*).ttf\?(.*)$/);
if (fontMatch) {
const relativeFontPath = `${fontMatch[1]}.ttf`; // trim the query parameter
const fontPath = path.join(path.dirname(module), relativeFontPath);
enqueue(fontPath);
return relativeFontPath;
}
enqueue(imagePath);
return url;
const imagePath = path.join(path.dirname(module), url);
const fileContents = fs.readFileSync(path.join(SRC_DIR, imagePath));
const MIME = /\.svg$/.test(url) ? 'image/svg+xml' : 'image/png';
let DATA = ';base64,' + fileContents.toString('base64');
if (!forceBase64 && /\.svg$/.test(url)) {
// .svg => url encode as explained at https://codepen.io/tigt/post/optimizing-svgs-in-data-uris
let newText = fileContents.toString()
.replace(/"/g, '\'')
.replace(/</g, '%3C')
.replace(/>/g, '%3E')
.replace(/&/g, '%26')
.replace(/#/g, '%23')
.replace(/\s+/g, ' ');
let encodedData = ',' + newText;
if (encodedData.length < DATA.length) {
DATA = encodedData;
}
}
return '"data:' + MIME + DATA + '"';
});
}

View File

@@ -51,7 +51,7 @@
"url": "vscode://schemas/keybindings"
},
{
"fileMatch": "vscode://defaultsettings/settings.json",
"fileMatch": "vscode://defaultsettings/*/*.json",
"url": "vscode://schemas/settings/default"
},
{

View File

@@ -469,11 +469,11 @@
},
{
"command": "git.clean",
"when": "config.git.enabled && gitOpenRepositoryCount != 0 && !gitFreshRepository"
"when": "config.git.enabled && gitOpenRepositoryCount != 0"
},
{
"command": "git.cleanAll",
"when": "config.git.enabled && gitOpenRepositoryCount != 0 && !gitFreshRepository"
"when": "config.git.enabled && gitOpenRepositoryCount != 0"
},
{
"command": "git.commit",
@@ -763,7 +763,7 @@
{
"command": "git.cleanAll",
"group": "5_stage",
"when": "scmProvider == git && !gitFreshRepository"
"when": "scmProvider == git"
},
{
"command": "git.stashIncludeUntracked",
@@ -831,7 +831,7 @@
},
{
"command": "git.cleanAll",
"when": "scmProvider == git && scmResourceGroup == workingTree && !gitFreshRepository",
"when": "scmProvider == git && scmResourceGroup == workingTree",
"group": "1_modification"
},
{
@@ -841,7 +841,7 @@
},
{
"command": "git.cleanAll",
"when": "scmProvider == git && scmResourceGroup == workingTree && !gitFreshRepository",
"when": "scmProvider == git && scmResourceGroup == workingTree",
"group": "inline"
},
{
@@ -850,6 +850,53 @@
"group": "inline"
}
],
"scm/resourceFolder/context": [
{
"command": "git.stage",
"when": "scmProvider == git && scmResourceGroup == merge",
"group": "1_modification"
},
{
"command": "git.stage",
"when": "scmProvider == git && scmResourceGroup == merge",
"group": "inline"
},
{
"command": "git.unstage",
"when": "scmProvider == git && scmResourceGroup == index",
"group": "1_modification"
},
{
"command": "git.unstage",
"when": "scmProvider == git && scmResourceGroup == index",
"group": "inline"
},
{
"command": "git.stage",
"when": "scmProvider == git && scmResourceGroup == workingTree",
"group": "1_modification"
},
{
"command": "git.clean",
"when": "scmProvider == git && scmResourceGroup == workingTree",
"group": "1_modification"
},
{
"command": "git.clean",
"when": "scmProvider == git && scmResourceGroup == workingTree",
"group": "inline"
},
{
"command": "git.stage",
"when": "scmProvider == git && scmResourceGroup == workingTree",
"group": "inline"
},
{
"command": "git.ignore",
"when": "scmProvider == git && scmResourceGroup == workingTree",
"group": "1_modification@3"
}
],
"scm/resourceState/context": [
{
"command": "git.stage",
@@ -933,12 +980,12 @@
},
{
"command": "git.clean",
"when": "scmProvider == git && scmResourceGroup == workingTree && !gitFreshRepository",
"when": "scmProvider == git && scmResourceGroup == workingTree",
"group": "1_modification"
},
{
"command": "git.clean",
"when": "scmProvider == git && scmResourceGroup == workingTree && !gitFreshRepository",
"when": "scmProvider == git && scmResourceGroup == workingTree",
"group": "inline"
},
{

View File

@@ -55,7 +55,7 @@
"command.syncRebase": "Sync (Rebase)",
"command.publish": "Publish Branch",
"command.showOutput": "Show Git Output",
"command.ignore": "Add File to .gitignore",
"command.ignore": "Add to .gitignore",
"command.stashIncludeUntracked": "Stash (Include Untracked)",
"command.stash": "Stash",
"command.stashPop": "Pop Stash...",

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { commands, Uri, Command, EventEmitter, Event, scm, SourceControl, SourceControlInputBox, SourceControlResourceGroup, SourceControlResourceState, SourceControlResourceDecorations, SourceControlInputBoxValidation, Disposable, ProgressLocation, window, workspace, WorkspaceEdit, ThemeColor, Decoration, Memento, SourceControlInputBoxValidationType, OutputChannel, LogLevel, env, ProgressOptions, CancellationToken } from 'vscode';
import { Uri, Command, EventEmitter, Event, scm, SourceControl, SourceControlInputBox, SourceControlResourceGroup, SourceControlResourceState, SourceControlResourceDecorations, SourceControlInputBoxValidation, Disposable, ProgressLocation, window, workspace, WorkspaceEdit, ThemeColor, Decoration, Memento, SourceControlInputBoxValidationType, OutputChannel, LogLevel, env, ProgressOptions, CancellationToken } from 'vscode';
import { Repository as BaseRepository, Commit, Stash, GitError, Submodule, CommitOptions, ForcePushMode } from './git';
import { anyEvent, filterEvent, eventToPromise, dispose, find, isDescendant, IDisposable, onceEvent, EmptyDisposable, debounceEvent, combinedDisposable } from './util';
import { memoize, throttle, debounce } from './decorators';
@@ -633,7 +633,6 @@ export class Repository implements Disposable {
private isRepositoryHuge = false;
private didWarnAboutLimit = false;
private isFreshRepository: boolean | undefined = undefined;
private disposables: Disposable[] = [];
@@ -1507,15 +1506,6 @@ export class Repository implements Disposable {
// set count badge
this.setCountBadge();
// Disable `Discard All Changes` for "fresh" repositories
// https://github.com/Microsoft/vscode/issues/43066
const isFreshRepository = !this._HEAD || !this._HEAD.commit;
if (this.isFreshRepository !== isFreshRepository) {
commands.executeCommand('setContext', 'gitFreshRepository', isFreshRepository);
this.isFreshRepository = isFreshRepository;
}
this._onDidChangeStatus.fire();
}

View File

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

View File

@@ -73,10 +73,10 @@ request-light@^0.2.4:
https-proxy-agent "^2.2.1"
vscode-nls "^4.0.0"
vscode-json-languageservice@^3.3.3:
version "3.3.3"
resolved "https://registry.yarnpkg.com/vscode-json-languageservice/-/vscode-json-languageservice-3.3.3.tgz#f7e512a2cd5e82fecbebf507d6fceaea47661297"
integrity sha512-5vL3OXTUuQpn6+tGd47dopio+7WwbtIZ07zfYMzAUX8eVWPZjfEsLeSWmQk5Xw+vwgu+j5zC4koz5UofLDGGRA==
vscode-json-languageservice@^3.3.4:
version "3.3.4"
resolved "https://registry.yarnpkg.com/vscode-json-languageservice/-/vscode-json-languageservice-3.3.4.tgz#4ff67580491d3a5dc469f4a78643f20adff0278d"
integrity sha512-/nuI4uDBfxyVyeGtBdYwP/tIaXYKOoymUOSozYKLzsmrDmu555gZpzc11LrARa96z92wSaa5hfjTtNMAoM2mxw==
dependencies:
jsonc-parser "^2.1.1"
vscode-languageserver-types "^3.15.0-next.2"

View File

@@ -182,13 +182,12 @@ pre.hljs code > div {
overflow: auto;
}
/** Theming */
pre code {
color: var(--vscode-editor-foreground);
tab-size: 4;
}
/** Theming */
.vscode-light pre {
background-color: rgba(220, 220, 220, 0.4);

View File

@@ -100,6 +100,7 @@ export default class MergeConflictCodeLensProvider implements vscode.CodeLensPro
this.codeLensRegistrationHandle = vscode.languages.registerCodeLensProvider([
{ scheme: 'file' },
{ scheme: 'untitled' },
{ scheme: 'vscode-userdata' },
], this);
}
}

View File

@@ -23,6 +23,7 @@
"support.type",
"entity.name.type",
"entity.name.namespace",
"entity.other.attribute",
"entity.name.scope-resolution",
"entity.name.class",
"storage.type.numeric.go",
@@ -76,7 +77,8 @@
"source.cpp keyword.operator.new",
"keyword.operator.delete",
"keyword.other.using",
"keyword.other.operator"
"keyword.other.operator",
"entity.name.operator"
],
"settings": {
"foreground": "#C586C0"
@@ -171,72 +173,11 @@
"foreground": "#d7ba7d"
}
},
// Scopes that are potentially C++ only follow
{
"scope": "source.cpp entity.name",
"scope": "entity.name.label",
"settings": {
"foreground": "#C8C8C8"
}
},
{
"scope": "source.cpp keyword.control.directive",
"settings": {
"foreground": "#9B9B9B"
}
},
{
"scope": "source.cpp entity.name.function.operator",
"settings": {
"foreground": "#B4B4B4"
}
},
{
"scope": "source.cpp entity.name.function.preprocessor",
"settings": {
"foreground": "#C586C0"
}
},
{
"scope": "source.cpp entity.name.label",
"settings": {
"foreground": "#C8C8C8"
}
},
{
"scope": "source.cpp entity.name.operator.custom-literal",
"settings": {
"foreground": "#DADADA"
}
},
{
"scope": "source.cpp entity.name.operator.custom-literal.number",
"settings": {
"foreground": "#B5CEA8"
}
},
{
"scope": "source.cpp entity.name.operator.custom-literal.string",
"settings": {
"foreground": "#ce9178"
}
},
{
"scope": "source.cpp variable.other.enummember",
"settings": {
"foreground": "#B8D7A3"
}
},
{
"scope": "source.cpp variable.other.property",
"settings": {
"foreground": "#DADADA"
}
},
{
"scope": "source.cpp variable.parameter",
"settings": {
"foreground": "#7F7F7F"
}
}
]
}

View File

@@ -44,7 +44,11 @@
},
{
"scope": [
"constant.numeric"
"constant.numeric",
"entity.name.operator.custom-literal.number",
"variable.other.enummember",
"keyword.operator.plus.exponent",
"keyword.operator.minus.exponent"
],
"settings": {
"foreground": "#b5cea8"
@@ -166,7 +170,10 @@
}
},
{
"scope": "meta.preprocessor",
"scope": [
"meta.preprocessor",
"keyword.control.directive"
],
"settings": {
"foreground": "#569cd6"
}
@@ -208,13 +215,19 @@
}
},
{
"scope": "storage.modifier",
"scope": [
"storage.modifier",
"keyword.operator.noexcept"
],
"settings": {
"foreground": "#569cd6"
}
},
{
"scope": "string",
"scope": [
"string",
"entity.name.operator.custom-literal.string",
],
"settings": {
"foreground": "#ce9178"
}
@@ -294,8 +307,11 @@
"keyword.operator.expression",
"keyword.operator.cast",
"keyword.operator.sizeof",
"keyword.operator.typeid",
"keyword.operator.alignas",
"keyword.operator.instanceof",
"keyword.operator.logical.python"
"keyword.operator.logical.python",
"keyword.operator.wordlike"
],
"settings": {
"foreground": "#569cd6"
@@ -347,4 +363,4 @@
}
}
]
}
}

View File

@@ -23,6 +23,7 @@
"support.type",
"entity.name.type",
"entity.name.namespace",
"entity.other.attribute",
"entity.name.scope-resolution",
"entity.name.class",
"storage.type.numeric.go",
@@ -76,7 +77,8 @@
"source.cpp keyword.operator.new",
"source.cpp keyword.operator.delete",
"keyword.other.using",
"keyword.other.operator"
"keyword.other.operator",
"entity.name.operator"
],
"settings": {
"foreground": "#AF00DB"
@@ -171,54 +173,11 @@
"foreground": "#ff0000"
}
},
// Scopes that are potentially C++ only follow
{
"scope": "source.cpp entity.name",
"scope": "entity.name.label",
"settings": {
"foreground": "#000000"
}
},
{
"scope": "source.cpp keyword.control.directive",
"settings": {
"foreground": "#808080"
}
},
{
"scope": "source.cpp entity.name.function.operator",
"settings": {
"foreground": "#008080"
}
},
{
"scope": "source.cpp entity.name.function.preprocessor",
"settings": {
"foreground": "#AF00DB"
}
},
{
"scope": "source.cpp entity.name.label",
"settings": {
"foreground": "#000000"
}
},
{
"scope": "source.cpp entity.name.operator.custom-literal.string",
"settings": {
"foreground": "#0451a5"
}
},
{
"scope": "source.cpp variable.other.enummember",
"settings": {
"foreground": "#2F4F4F"
}
},
{
"scope": "source.cpp variable.parameter",
"settings": {
"foreground": "#808080"
}
}
]
}

View File

@@ -4,7 +4,10 @@
"include": "./light_defaults.json",
"tokenColors": [
{
"scope": ["meta.embedded", "source.groovy.embedded"],
"scope": [
"meta.embedded",
"source.groovy.embedded"
],
"settings": {
"foreground": "#000000ff"
}
@@ -41,7 +44,11 @@
},
{
"scope": [
"constant.numeric"
"constant.numeric",
"entity.name.operator.custom-literal.number",
"variable.other.enummember",
"keyword.operator.plus.exponent",
"keyword.operator.minus.exponent"
],
"settings": {
"foreground": "#09885a"
@@ -161,7 +168,10 @@
}
},
{
"scope": "meta.preprocessor",
"scope": [
"meta.preprocessor",
"keyword.control.directive"
],
"settings": {
"foreground": "#0000ff"
}
@@ -197,13 +207,19 @@
}
},
{
"scope": "storage.modifier",
"scope": [
"storage.modifier",
"keyword.operator.noexcept"
],
"settings": {
"foreground": "#0000ff"
}
},
{
"scope": "string",
"scope": [
"string",
"entity.name.operator.custom-literal.string",
],
"settings": {
"foreground": "#a31515"
}
@@ -315,8 +331,11 @@
"keyword.operator.expression",
"keyword.operator.cast",
"keyword.operator.sizeof",
"keyword.operator.typeid",
"keyword.operator.alignas",
"keyword.operator.instanceof",
"keyword.operator.logical.python"
"keyword.operator.logical.python",
"keyword.operator.wordlike"
],
"settings": {
"foreground": "#0000ff"
@@ -368,4 +387,4 @@
}
}
]
}
}

View File

@@ -167,7 +167,7 @@
"vinyl": "^2.0.0",
"vinyl-fs": "^3.0.0",
"vsce": "1.48.0",
"vscode-debugprotocol": "1.36.0",
"vscode-debugprotocol": "1.37.0",
"vscode-nls-dev": "^3.3.1",
"webpack": "^4.16.5",
"webpack-cli": "^3.3.8",

View File

@@ -34,7 +34,7 @@ if grep -qi Microsoft /proc/version; then
WSL_EXT_WLOC=$(cmd.exe /C type %TEMP%\\remote-wsl-loc.txt)
cd "$CWD"
else
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --locate-extension $WSL_EXT_ID >/tmp/remote-wsl-loc.txt
ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" --locate-extension $WSL_EXT_ID >/tmp/remote-wsl-loc.txt 2>/dev/null
WSL_EXT_WLOC=$(cat /tmp/remote-wsl-loc.txt)
fi
if [ -n "$WSL_EXT_WLOC" ]; then

View File

@@ -15,9 +15,9 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { SIDE_BAR_BACKGROUND } from 'vs/workbench/common/theme';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
import { IThemeService, ITheme } from 'vs/platform/theme/common/themeService';
import { URI } from 'vs/base/common/uri';
import * as azdata from 'azdata';
import { Button } from 'sql/base/browser/ui/button/button';
@@ -30,6 +30,7 @@ import * as TelemetryKeys from 'sql/platform/telemetry/common/telemetryKeys';
import { ILogService } from 'vs/platform/log/common/log';
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
import { IOpenerService } from 'vs/platform/opener/common/opener';
// TODO: Make the help link 1) extensible (01/08/2018, https://github.com/Microsoft/azuredatastudio/issues/450)
// in case that other non-Azure sign in is to be used
@@ -70,10 +71,10 @@ export class FirewallRuleDialog extends Modal {
@IContextViewService private _contextViewService: IContextViewService,
@ITelemetryService telemetryService: ITelemetryService,
@IContextKeyService contextKeyService: IContextKeyService,
@IWindowsService private _windowsService: IWindowsService,
@IClipboardService clipboardService: IClipboardService,
@ILogService logService: ILogService,
@ITextResourcePropertiesService textResourcePropertiesService: ITextResourcePropertiesService
@ITextResourcePropertiesService textResourcePropertiesService: ITextResourcePropertiesService,
@IOpenerService private readonly openerService: IOpenerService
) {
super(
localize('createNewFirewallRule', "Create new firewall rule"),
@@ -125,7 +126,7 @@ export class FirewallRuleDialog extends Modal {
this._helpLink.setAttribute('href', firewallHelpUri);
this._helpLink.innerHTML += localize('firewallRuleHelpDescription', "Learn more about firewall settings");
this._helpLink.onclick = () => {
this._windowsService.openExternal(firewallHelpUri);
this.openerService.open(URI.parse(firewallHelpUri));
};
// Create account picker with event handling

View File

@@ -12,7 +12,6 @@ import { URI } from 'vs/base/common/uri';
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import { INotificationService, Severity } from 'vs/platform/notification/common/notification';
import { localize } from 'vs/nls';
import { IWindowService } from 'vs/platform/windows/common/windows';
@extHostNamedCustomer(SqlMainContext.MainThreadExtensionManagement)
export class MainThreadExtensionManagement extends Disposable implements MainThreadExtensionManagementShape {
@@ -23,8 +22,7 @@ export class MainThreadExtensionManagement extends Disposable implements MainThr
extHostContext: IExtHostContext,
@IExtensionManagementService private _extensionService: IExtensionManagementService,
@IConfigurationService private _configurationService: IConfigurationService,
@INotificationService private _notificationService: INotificationService,
@IWindowService protected readonly _windowService: IWindowService
@INotificationService private _notificationService: INotificationService
) {
super();
}
@@ -53,9 +51,6 @@ export class MainThreadExtensionManagement extends Disposable implements MainThr
this._configurationService.updateValue('workbench.enableObsoleteApiUsageNotification', false, ConfigurationTarget.USER);
},
isSecondary: true
}, {
label: localize('devTools', "Open Developer Tools"),
run: () => this._windowService.openDevTools()
}]);
this._obsoleteExtensionApiUsageNotificationShown = true;
}

View File

@@ -12,10 +12,11 @@ import { Task } from 'sql/platform/tasks/browser/tasksRegistry';
import { ObjectMetadata } from 'azdata';
import { Action } from 'vs/base/common/actions';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import * as nls from 'vs/nls';
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { IInsightsConfig } from 'sql/platform/dashboard/browser/insightRegistry';
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { URI } from 'vs/base/common/uri';
export interface BaseActionContext {
object?: ObjectMetadata;
@@ -85,6 +86,6 @@ export class ConfigureDashboardAction extends Task {
}
runTask(accessor: ServicesAccessor): Promise<void> {
return accessor.get<IWindowsService>(IWindowsService).openExternal(ConfigureDashboardAction.configHelpUri).then();
return accessor.get(IOpenerService).open(URI.parse(ConfigureDashboardAction.configHelpUri)).then();
}
}

View File

@@ -4,28 +4,31 @@
*--------------------------------------------------------------------------------------------*/
import { Action } from 'vs/base/common/actions';
import { IWindowsService } from 'vs/platform/windows/common/windows';
import { IOpenerService } from 'vs/platform/opener/common/opener';
//tslint:disable-next-line:layering
import { ElectronMainService } from 'vs/platform/electron/electron-main/electronMainService';
//tslint:disable-next-line:layering
import { IElectronService } from 'vs/platform/electron/node/electron';
import { URI } from 'vs/base/common/uri';
export class ShowFileInFolderAction extends Action {
constructor(private path: string, label: string, private windowsService: ElectronMainService) {
constructor(private path: string, label: string, @IElectronService private windowsService: ElectronMainService) {
super('showItemInFolder.action.id', label);
}
run(): Promise<void> {
return this.windowsService.showItemInFolder(this.path);
return this.windowsService.showItemInFolder(undefined, this.path);
}
}
export class OpenFileInFolderAction extends Action {
constructor(private path: string, label: string, private windowsService: IWindowsService) {
constructor(private path: string, label: string, @IOpenerService private openerService: IOpenerService) {
super('showItemInFolder.action.id', label);
}
run() {
return this.windowsService.openExternal(this.path);
return this.openerService.open(URI.file(this.path));
}
}

View File

@@ -20,6 +20,7 @@ import { IInsightOptions } from 'sql/workbench/parts/charts/common/interfaces';
import { IFileService } from 'vs/platform/files/common/files';
import { IFileDialogService } from 'vs/platform/dialogs/common/dialogs';
import { VSBuffer } from 'vs/base/common/buffer';
import { IOpenerService } from 'vs/platform/opener/common/opener';
export interface IChartActionContext {
options: IInsightOptions;
@@ -142,10 +143,10 @@ export class SaveImageAction extends Action {
public static ICON = 'saveAsImage';
constructor(
@IWindowsService private readonly windowsService: IWindowsService,
@INotificationService private readonly notificationService: INotificationService,
@IFileService private readonly fileService: IFileService,
@IFileDialogService private readonly fileDialogService: IFileDialogService
@IFileDialogService private readonly fileDialogService: IFileDialogService,
@IOpenerService private readonly openerService: IOpenerService
) {
super(SaveImageAction.ID, SaveImageAction.LABEL, SaveImageAction.ICON);
}
@@ -168,7 +169,7 @@ export class SaveImageAction extends Action {
if (err) {
this.notificationService.error(err.message);
} else {
this.windowsService.openExternal(filePath.toString());
this.openerService.open(filePath, { openExternal: true });
this.notificationService.notify({
severity: Severity.Error,
message: localize('chartSaved', "Saved Chart to path: {0}", filePath.toString())

View File

@@ -35,6 +35,7 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import { ObjectExplorerActionsContext } from 'sql/workbench/parts/objectExplorer/browser/objectExplorerActions';
import { ItemContextKey } from 'sql/workbench/parts/dashboard/browser/widgets/explorer/explorerTreeContext';
import { ManageActionContext } from 'sql/workbench/browser/actions';
import { IHostService } from 'vs/workbench/services/host/browser/host';
import { MarkdownOutputComponent } from 'sql/workbench/parts/notebook/browser/outputs/markdownOutput.component';
import { registerCellComponent } from 'sql/platform/notebooks/common/outputRegistry';
import { TextCellComponent } from 'sql/workbench/parts/notebook/browser/cellViews/textCell.component';
@@ -130,6 +131,7 @@ registerAction({
const viewletService = accessor.get(IViewletService);
const workspaceEditingService = accessor.get(IWorkspaceEditingService);
const windowService = accessor.get(IWindowService);
const hostService = accessor.get(IHostService);
let folders = [];
if (!options.folderPath) {
return;
@@ -141,7 +143,7 @@ registerAction({
return windowService.openWindow([{ folderUri: folders[0] }], { forceNewWindow: options.forceNewWindow });
}
else {
return windowService.reloadWindow();
return hostService.reload();
}
}
});

View File

@@ -5,7 +5,7 @@
@font-face {
font-family: "codicon";
src: url("./codicon.ttf?e042d2dda15ef7b36b910e3edf539f26") format("truetype");
src: url("./codicon.ttf?3b584136fb1f0186a1ee578cdcb5240b") format("truetype");
}
.codicon[class*='codicon-'] {
@@ -203,152 +203,153 @@
.codicon-folder-active:before { content: "\f162" }
.codicon-folder-opened:before { content: "\f163" }
.codicon-folder:before { content: "\f164" }
.codicon-gift:before { content: "\f165" }
.codicon-gist-secret:before { content: "\f166" }
.codicon-gist:before { content: "\f167" }
.codicon-git-commit:before { content: "\f168" }
.codicon-git-compare:before { content: "\f169" }
.codicon-git-merge:before { content: "\f16a" }
.codicon-github-action:before { content: "\f16b" }
.codicon-github-alt:before { content: "\f16c" }
.codicon-github:before { content: "\f16d" }
.codicon-globe:before { content: "\f16e" }
.codicon-go-to-file:before { content: "\f16f" }
.codicon-grabber:before { content: "\f170" }
.codicon-graph:before { content: "\f171" }
.codicon-gripper:before { content: "\f172" }
.codicon-heart:before { content: "\f173" }
.codicon-history:before { content: "\f174" }
.codicon-home:before { content: "\f175" }
.codicon-horizontal-rule:before { content: "\f176" }
.codicon-hubot:before { content: "\f177" }
.codicon-inbox:before { content: "\f178" }
.codicon-interface:before { content: "\f179" }
.codicon-issue-closed:before { content: "\f17a" }
.codicon-issue-reopened:before { content: "\f17b" }
.codicon-issues:before { content: "\f17c" }
.codicon-italic:before { content: "\f17d" }
.codicon-jersey:before { content: "\f17e" }
.codicon-json:before { content: "\f17f" }
.codicon-kebab-vertical:before { content: "\f180" }
.codicon-key:before { content: "\f181" }
.codicon-keyword:before { content: "\f182" }
.codicon-law:before { content: "\f183" }
.codicon-lightbulb-autofix:before { content: "\f184" }
.codicon-link-external:before { content: "\f185" }
.codicon-link:before { content: "\f186" }
.codicon-list-ordered:before { content: "\f187" }
.codicon-list-unordered:before { content: "\f188" }
.codicon-live-share:before { content: "\f189" }
.codicon-loading:before { content: "\f18a" }
.codicon-location:before { content: "\f18b" }
.codicon-mail-read:before { content: "\f18c" }
.codicon-mail:before { content: "\f18d" }
.codicon-markdown:before { content: "\f18e" }
.codicon-megaphone:before { content: "\f18f" }
.codicon-mention:before { content: "\f190" }
.codicon-method:before { content: "\f191" }
.codicon-milestone:before { content: "\f192" }
.codicon-misc:before { content: "\f193" }
.codicon-mortar-board:before { content: "\f194" }
.codicon-move:before { content: "\f195" }
.codicon-multiple-windows:before { content: "\f196" }
.codicon-mute:before { content: "\f197" }
.codicon-namespace:before { content: "\f198" }
.codicon-no-newline:before { content: "\f199" }
.codicon-note:before { content: "\f19a" }
.codicon-numeric:before { content: "\f19b" }
.codicon-octoface:before { content: "\f19c" }
.codicon-open-preview:before { content: "\f19d" }
.codicon-operator:before { content: "\f19e" }
.codicon-package:before { content: "\f19f" }
.codicon-paintcan:before { content: "\f1a0" }
.codicon-parameter:before { content: "\f1a1" }
.codicon-pause:before { content: "\f1a2" }
.codicon-pin:before { content: "\f1a3" }
.codicon-play:before { content: "\f1a4" }
.codicon-plug:before { content: "\f1a5" }
.codicon-preserve-case:before { content: "\f1a6" }
.codicon-preview:before { content: "\f1a7" }
.codicon-project:before { content: "\f1a8" }
.codicon-property:before { content: "\f1a9" }
.codicon-pulse:before { content: "\f1aa" }
.codicon-question:before { content: "\f1ab" }
.codicon-quote:before { content: "\f1ac" }
.codicon-radio-tower:before { content: "\f1ad" }
.codicon-reactions:before { content: "\f1ae" }
.codicon-references:before { content: "\f1af" }
.codicon-refresh:before { content: "\f1b0" }
.codicon-regex:before { content: "\f1b1" }
.codicon-remote:before { content: "\f1b2" }
.codicon-remove:before { content: "\f1b3" }
.codicon-replace-all:before { content: "\f1b4" }
.codicon-replace:before { content: "\f1b5" }
.codicon-repo-clone:before { content: "\f1b6" }
.codicon-repo-force-push:before { content: "\f1b7" }
.codicon-repo-pull:before { content: "\f1b8" }
.codicon-repo-push:before { content: "\f1b9" }
.codicon-report:before { content: "\f1ba" }
.codicon-request-changes:before { content: "\f1bb" }
.codicon-restart:before { content: "\f1bc" }
.codicon-rocket:before { content: "\f1bd" }
.codicon-root-folder-opened:before { content: "\f1be" }
.codicon-root-folder:before { content: "\f1bf" }
.codicon-rss:before { content: "\f1c0" }
.codicon-ruby:before { content: "\f1c1" }
.codicon-ruler:before { content: "\f1c2" }
.codicon-save-all:before { content: "\f1c3" }
.codicon-save-as:before { content: "\f1c4" }
.codicon-save:before { content: "\f1c5" }
.codicon-screen-full:before { content: "\f1c6" }
.codicon-screen-normal:before { content: "\f1c7" }
.codicon-search-stop:before { content: "\f1c8" }
.codicon-selection:before { content: "\f1c9" }
.codicon-server:before { content: "\f1ca" }
.codicon-settings:before { content: "\f1cb" }
.codicon-shield:before { content: "\f1cc" }
.codicon-smiley:before { content: "\f1cd" }
.codicon-snippet:before { content: "\f1ce" }
.codicon-sort-precedence:before { content: "\f1cf" }
.codicon-split-horizontal:before { content: "\f1d0" }
.codicon-split-vertical:before { content: "\f1d1" }
.codicon-squirrel:before { content: "\f1d2" }
.codicon-star-empty:before { content: "\f1d3" }
.codicon-star-full:before { content: "\f1d4" }
.codicon-star-half:before { content: "\f1d5" }
.codicon-start:before { content: "\f1d6" }
.codicon-step-into:before { content: "\f1d7" }
.codicon-step-out:before { content: "\f1d8" }
.codicon-step-over:before { content: "\f1d9" }
.codicon-string:before { content: "\f1da" }
.codicon-structure:before { content: "\f1db" }
.codicon-tasklist:before { content: "\f1dc" }
.codicon-telescope:before { content: "\f1dd" }
.codicon-text-size:before { content: "\f1de" }
.codicon-three-bars:before { content: "\f1df" }
.codicon-thumbsdown:before { content: "\f1e0" }
.codicon-thumbsup:before { content: "\f1e1" }
.codicon-tools:before { content: "\f1e2" }
.codicon-trash:before { content: "\f1e3" }
.codicon-triangle-down:before { content: "\f1e4" }
.codicon-triangle-left:before { content: "\f1e5" }
.codicon-triangle-right:before { content: "\f1e6" }
.codicon-triangle-up:before { content: "\f1e7" }
.codicon-twitter:before { content: "\f1e8" }
.codicon-unfold:before { content: "\f1e9" }
.codicon-unlock:before { content: "\f1ea" }
.codicon-unmute:before { content: "\f1eb" }
.codicon-unverified:before { content: "\f1ec" }
.codicon-variable:before { content: "\f1ed" }
.codicon-verified:before { content: "\f1ee" }
.codicon-versions:before { content: "\f1ef" }
.codicon-vm-active:before { content: "\f1f0" }
.codicon-vm-outline:before { content: "\f1f1" }
.codicon-vm-running:before { content: "\f1f2" }
.codicon-watch:before { content: "\f1f3" }
.codicon-whitespace:before { content: "\f1f4" }
.codicon-whole-word:before { content: "\f1f5" }
.codicon-window:before { content: "\f1f6" }
.codicon-word-wrap:before { content: "\f1f7" }
.codicon-zoom-in:before { content: "\f1f8" }
.codicon-zoom-out:before { content: "\f1f9" }
.codicon-gear:before { content: "\f165" }
.codicon-gift:before { content: "\f166" }
.codicon-gist-secret:before { content: "\f167" }
.codicon-gist:before { content: "\f168" }
.codicon-git-commit:before { content: "\f169" }
.codicon-git-compare:before { content: "\f16a" }
.codicon-git-merge:before { content: "\f16b" }
.codicon-github-action:before { content: "\f16c" }
.codicon-github-alt:before { content: "\f16d" }
.codicon-github:before { content: "\f16e" }
.codicon-globe:before { content: "\f16f" }
.codicon-go-to-file:before { content: "\f170" }
.codicon-grabber:before { content: "\f171" }
.codicon-graph:before { content: "\f172" }
.codicon-gripper:before { content: "\f173" }
.codicon-heart:before { content: "\f174" }
.codicon-history:before { content: "\f175" }
.codicon-home:before { content: "\f176" }
.codicon-horizontal-rule:before { content: "\f177" }
.codicon-hubot:before { content: "\f178" }
.codicon-inbox:before { content: "\f179" }
.codicon-interface:before { content: "\f17a" }
.codicon-issue-closed:before { content: "\f17b" }
.codicon-issue-reopened:before { content: "\f17c" }
.codicon-issues:before { content: "\f17d" }
.codicon-italic:before { content: "\f17e" }
.codicon-jersey:before { content: "\f17f" }
.codicon-json:before { content: "\f180" }
.codicon-kebab-vertical:before { content: "\f181" }
.codicon-key:before { content: "\f182" }
.codicon-keyword:before { content: "\f183" }
.codicon-law:before { content: "\f184" }
.codicon-lightbulb-autofix:before { content: "\f185" }
.codicon-link-external:before { content: "\f186" }
.codicon-link:before { content: "\f187" }
.codicon-list-ordered:before { content: "\f188" }
.codicon-list-unordered:before { content: "\f189" }
.codicon-live-share:before { content: "\f18a" }
.codicon-loading:before { content: "\f18b" }
.codicon-location:before { content: "\f18c" }
.codicon-mail-read:before { content: "\f18d" }
.codicon-mail:before { content: "\f18e" }
.codicon-markdown:before { content: "\f18f" }
.codicon-megaphone:before { content: "\f190" }
.codicon-mention:before { content: "\f191" }
.codicon-method:before { content: "\f192" }
.codicon-milestone:before { content: "\f193" }
.codicon-misc:before { content: "\f194" }
.codicon-mortar-board:before { content: "\f195" }
.codicon-move:before { content: "\f196" }
.codicon-multiple-windows:before { content: "\f197" }
.codicon-mute:before { content: "\f198" }
.codicon-namespace:before { content: "\f199" }
.codicon-no-newline:before { content: "\f19a" }
.codicon-note:before { content: "\f19b" }
.codicon-numeric:before { content: "\f19c" }
.codicon-octoface:before { content: "\f19d" }
.codicon-open-preview:before { content: "\f19e" }
.codicon-operator:before { content: "\f19f" }
.codicon-package:before { content: "\f1a0" }
.codicon-paintcan:before { content: "\f1a1" }
.codicon-parameter:before { content: "\f1a2" }
.codicon-pause:before { content: "\f1a3" }
.codicon-pin:before { content: "\f1a4" }
.codicon-play:before { content: "\f1a5" }
.codicon-plug:before { content: "\f1a6" }
.codicon-preserve-case:before { content: "\f1a7" }
.codicon-preview:before { content: "\f1a8" }
.codicon-project:before { content: "\f1a9" }
.codicon-property:before { content: "\f1aa" }
.codicon-pulse:before { content: "\f1ab" }
.codicon-question:before { content: "\f1ac" }
.codicon-quote:before { content: "\f1ad" }
.codicon-radio-tower:before { content: "\f1ae" }
.codicon-reactions:before { content: "\f1af" }
.codicon-references:before { content: "\f1b0" }
.codicon-refresh:before { content: "\f1b1" }
.codicon-regex:before { content: "\f1b2" }
.codicon-remote:before { content: "\f1b3" }
.codicon-remove:before { content: "\f1b4" }
.codicon-replace-all:before { content: "\f1b5" }
.codicon-replace:before { content: "\f1b6" }
.codicon-repo-clone:before { content: "\f1b7" }
.codicon-repo-force-push:before { content: "\f1b8" }
.codicon-repo-pull:before { content: "\f1b9" }
.codicon-repo-push:before { content: "\f1ba" }
.codicon-report:before { content: "\f1bb" }
.codicon-request-changes:before { content: "\f1bc" }
.codicon-restart:before { content: "\f1bd" }
.codicon-rocket:before { content: "\f1be" }
.codicon-root-folder-opened:before { content: "\f1bf" }
.codicon-root-folder:before { content: "\f1c0" }
.codicon-rss:before { content: "\f1c1" }
.codicon-ruby:before { content: "\f1c2" }
.codicon-ruler:before { content: "\f1c3" }
.codicon-save-all:before { content: "\f1c4" }
.codicon-save-as:before { content: "\f1c5" }
.codicon-save:before { content: "\f1c6" }
.codicon-screen-full:before { content: "\f1c7" }
.codicon-screen-normal:before { content: "\f1c8" }
.codicon-search-stop:before { content: "\f1c9" }
.codicon-selection:before { content: "\f1ca" }
.codicon-server:before { content: "\f1cb" }
.codicon-settings:before { content: "\f1cc" }
.codicon-shield:before { content: "\f1cd" }
.codicon-smiley:before { content: "\f1ce" }
.codicon-snippet:before { content: "\f1cf" }
.codicon-sort-precedence:before { content: "\f1d0" }
.codicon-split-horizontal:before { content: "\f1d1" }
.codicon-split-vertical:before { content: "\f1d2" }
.codicon-squirrel:before { content: "\f1d3" }
.codicon-star-empty:before { content: "\f1d4" }
.codicon-star-full:before { content: "\f1d5" }
.codicon-star-half:before { content: "\f1d6" }
.codicon-start:before { content: "\f1d7" }
.codicon-step-into:before { content: "\f1d8" }
.codicon-step-out:before { content: "\f1d9" }
.codicon-step-over:before { content: "\f1da" }
.codicon-string:before { content: "\f1db" }
.codicon-structure:before { content: "\f1dc" }
.codicon-tasklist:before { content: "\f1dd" }
.codicon-telescope:before { content: "\f1de" }
.codicon-text-size:before { content: "\f1df" }
.codicon-three-bars:before { content: "\f1e0" }
.codicon-thumbsdown:before { content: "\f1e1" }
.codicon-thumbsup:before { content: "\f1e2" }
.codicon-tools:before { content: "\f1e3" }
.codicon-trash:before { content: "\f1e4" }
.codicon-triangle-down:before { content: "\f1e5" }
.codicon-triangle-left:before { content: "\f1e6" }
.codicon-triangle-right:before { content: "\f1e7" }
.codicon-triangle-up:before { content: "\f1e8" }
.codicon-twitter:before { content: "\f1e9" }
.codicon-unfold:before { content: "\f1ea" }
.codicon-unlock:before { content: "\f1eb" }
.codicon-unmute:before { content: "\f1ec" }
.codicon-unverified:before { content: "\f1ed" }
.codicon-variable:before { content: "\f1ee" }
.codicon-verified:before { content: "\f1ef" }
.codicon-versions:before { content: "\f1f0" }
.codicon-vm-active:before { content: "\f1f1" }
.codicon-vm-outline:before { content: "\f1f2" }
.codicon-vm-running:before { content: "\f1f3" }
.codicon-watch:before { content: "\f1f4" }
.codicon-whitespace:before { content: "\f1f5" }
.codicon-whole-word:before { content: "\f1f6" }
.codicon-window:before { content: "\f1f7" }
.codicon-word-wrap:before { content: "\f1f8" }
.codicon-zoom-in:before { content: "\f1f9" }
.codicon-zoom-out:before { content: "\f1fa" }

View File

@@ -1,24 +0,0 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { escape } from 'vs/base/common/strings';
export function renderCodicons(text: string): string {
return escape(text);
}
export class CodiconLabel {
private _container: HTMLElement;
constructor(container: HTMLElement) {
this._container = container;
}
set text(text: string) {
this._container.innerHTML = renderCodicons(text || '');
}
}

View File

@@ -295,7 +295,7 @@ export class DropdownMenuActionViewItem extends BaseActionViewItem {
render(container: HTMLElement): void {
const labelRenderer: ILabelRenderer = (el: HTMLElement): IDisposable | null => {
this.element = append(el, $('a.action-label.icon'));
this.element = append(el, $('a.action-label.codicon'));
if (this.clazz) {
addClasses(this.element, this.clazz);
}

View File

@@ -32,6 +32,7 @@ export interface IReplaceInputOptions extends IReplaceInputStyles {
export interface IReplaceInputStyles extends IInputBoxStyles {
inputActiveOptionBorder?: Color;
inputActiveOptionBackground?: Color;
}
const NLS_DEFAULT_LABEL = nls.localize('defaultLabel', "input");
@@ -44,7 +45,8 @@ export class PreserveCaseCheckbox extends Checkbox {
actionClassName: 'codicon-preserve-case',
title: NLS_PRESERVE_CASE_LABEL + opts.appendTitle,
isChecked: opts.isChecked,
inputActiveOptionBorder: opts.inputActiveOptionBorder
inputActiveOptionBorder: opts.inputActiveOptionBorder,
inputActiveOptionBackground: opts.inputActiveOptionBackground
});
}
}
@@ -60,6 +62,7 @@ export class ReplaceInput extends Widget {
private fixFocusOnOptionClickEnabled = true;
private inputActiveOptionBorder?: Color;
private inputActiveOptionBackground?: Color;
private inputBackground?: Color;
private inputForeground?: Color;
private inputBorder?: Color;
@@ -105,6 +108,7 @@ export class ReplaceInput extends Widget {
this.label = options.label || NLS_DEFAULT_LABEL;
this.inputActiveOptionBorder = options.inputActiveOptionBorder;
this.inputActiveOptionBackground = options.inputActiveOptionBackground;
this.inputBackground = options.inputBackground;
this.inputForeground = options.inputForeground;
this.inputBorder = options.inputBorder;
@@ -181,6 +185,7 @@ export class ReplaceInput extends Widget {
public style(styles: IReplaceInputStyles): void {
this.inputActiveOptionBorder = styles.inputActiveOptionBorder;
this.inputActiveOptionBackground = styles.inputActiveOptionBackground;
this.inputBackground = styles.inputBackground;
this.inputForeground = styles.inputForeground;
this.inputBorder = styles.inputBorder;
@@ -202,6 +207,7 @@ export class ReplaceInput extends Widget {
if (this.domNode) {
const checkBoxStyles: ICheckboxStyles = {
inputActiveOptionBorder: this.inputActiveOptionBorder,
inputActiveOptionBackground: this.inputActiveOptionBackground,
};
this.preserveCase.style(checkBoxStyles);
@@ -281,7 +287,8 @@ export class ReplaceInput extends Widget {
this.preserveCase = this._register(new PreserveCaseCheckbox({
appendTitle: '',
isChecked: false,
inputActiveOptionBorder: this.inputActiveOptionBorder
inputActiveOptionBorder: this.inputActiveOptionBorder,
inputActiveOptionBackground: this.inputActiveOptionBackground,
}));
this._register(this.preserveCase.onChange(viaKeyboard => {
this._onDidOptionChange.fire(viaKeyboard);

View File

@@ -188,12 +188,12 @@ class BranchNode implements ISplitView, IDisposable {
return this.orientation === Orientation.HORIZONTAL ? this.maximumSize : this.maximumOrthogonalSize;
}
private _onDidChange = new Emitter<number | undefined>();
private readonly _onDidChange = new Emitter<number | undefined>();
readonly onDidChange: Event<number | undefined> = this._onDidChange.event;
private childrenChangeDisposable: IDisposable = Disposable.None;
private _onDidSashReset = new Emitter<number[]>();
private readonly _onDidSashReset = new Emitter<number[]>();
readonly onDidSashReset: Event<number[]> = this._onDidSashReset.event;
private splitviewSashResetDisposable: IDisposable = Disposable.None;
private childrenSashResetDisposable: IDisposable = Disposable.None;
@@ -539,7 +539,7 @@ class LeafNode implements ISplitView, IDisposable {
this._onDidSetLinkedNode.fire(undefined);
}
private _onDidSetLinkedNode = new Emitter<number | undefined>();
private readonly _onDidSetLinkedNode = new Emitter<number | undefined>();
private _onDidViewChange: Event<number | undefined>;
readonly onDidChange: Event<number | undefined>;

View File

@@ -79,7 +79,10 @@ export interface IKeyboardNavigationLabelProvider<T> {
* element always match.
*/
getKeyboardNavigationLabel(element: T): { toString(): string | undefined; } | undefined;
mightProducePrintableCharacter?(event: IKeyboardEvent): boolean;
}
export interface IKeyboardNavigationDelegate {
mightProducePrintableCharacter(event: IKeyboardEvent): boolean;
}
export const enum ListDragOverEffect {

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import 'vs/css!./list';
import { IDisposable } from 'vs/base/common/lifecycle';
import { IDisposable, Disposable } from 'vs/base/common/lifecycle';
import { range } from 'vs/base/common/arrays';
import { IListVirtualDelegate, IListRenderer, IListEvent, IListContextMenuEvent } from './list';
import { List, IListStyles, IListOptions } from './listWidget';
@@ -32,7 +32,7 @@ class PagedRenderer<TElement, TTemplateData> implements IListRenderer<number, IT
renderTemplate(container: HTMLElement): ITemplateData<TTemplateData> {
const data = this.renderer.renderTemplate(container);
return { data, disposable: { dispose: () => { } } };
return { data, disposable: Disposable.None };
}
renderElement(index: number, _: number, data: ITemplateData<TTemplateData>, height: number | undefined): void {
@@ -127,7 +127,7 @@ export class PagedList<T> implements IDisposable {
}
get onPin(): Event<IListEvent<T>> {
return Event.map(this.list.onPin, ({ elements, indexes }) => ({ elements: elements.map(e => this._model.get(e)), indexes }));
return Event.map(this.list.onDidPin, ({ elements, indexes }) => ({ elements: elements.map(e => this._model.get(e)), indexes }));
}
get onContextMenu(): Event<IListContextMenuEvent<T>> {

View File

@@ -190,7 +190,7 @@ export class ListView<T> implements ISpliceable<T>, IDisposable {
private readonly disposables: DisposableStore = new DisposableStore();
private _onDidChangeContentHeight = new Emitter<number>();
private readonly _onDidChangeContentHeight = new Emitter<number>();
readonly onDidChangeContentHeight: Event<number> = Event.latch(this._onDidChangeContentHeight.event);
get contentHeight(): number { return this.rangeMap.size; }

View File

@@ -16,7 +16,7 @@ import { KeyCode } from 'vs/base/common/keyCodes';
import { StandardKeyboardEvent, IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { Event, Emitter, EventBufferer } from 'vs/base/common/event';
import { domEvent } from 'vs/base/browser/event';
import { IListVirtualDelegate, IListRenderer, IListEvent, IListContextMenuEvent, IListMouseEvent, IListTouchEvent, IListGestureEvent, IIdentityProvider, IKeyboardNavigationLabelProvider, IListDragAndDrop, IListDragOverReaction, ListAriaRootRole, ListError } from './list';
import { IListVirtualDelegate, IListRenderer, IListEvent, IListContextMenuEvent, IListMouseEvent, IListTouchEvent, IListGestureEvent, IIdentityProvider, IKeyboardNavigationLabelProvider, IListDragAndDrop, IListDragOverReaction, ListAriaRootRole, ListError, IKeyboardNavigationDelegate } from './list';
import { ListView, IListViewOptions, IListViewDragAndDrop, IAriaProvider } from './listView';
import { Color } from 'vs/base/common/color';
import { mixin } from 'vs/base/common/objects';
@@ -110,7 +110,7 @@ class Trait<T> implements ISpliceable<boolean>, IDisposable {
private indexes: number[] = [];
private sortedIndexes: number[] = [];
private _onChange = new Emitter<ITraitChangeEvent>();
private readonly _onChange = new Emitter<ITraitChangeEvent>();
readonly onChange: Event<ITraitChangeEvent> = this._onChange.event;
get trait(): string { return this._trait; }
@@ -176,7 +176,7 @@ class Trait<T> implements ISpliceable<boolean>, IDisposable {
}
dispose() {
this._onChange = dispose(this._onChange);
dispose(this._onChange);
}
}
@@ -322,16 +322,18 @@ enum TypeLabelControllerState {
Typing
}
export function mightProducePrintableCharacter(event: IKeyboardEvent): boolean {
if (event.ctrlKey || event.metaKey || event.altKey) {
return false;
}
export const DefaultKeyboardNavigationDelegate = new class implements IKeyboardNavigationDelegate {
mightProducePrintableCharacter(event: IKeyboardEvent): boolean {
if (event.ctrlKey || event.metaKey || event.altKey) {
return false;
}
return (event.keyCode >= KeyCode.KEY_A && event.keyCode <= KeyCode.KEY_Z)
|| (event.keyCode >= KeyCode.KEY_0 && event.keyCode <= KeyCode.KEY_9)
|| (event.keyCode >= KeyCode.NUMPAD_0 && event.keyCode <= KeyCode.NUMPAD_9)
|| (event.keyCode >= KeyCode.US_SEMICOLON && event.keyCode <= KeyCode.US_QUOTE);
}
return (event.keyCode >= KeyCode.KEY_A && event.keyCode <= KeyCode.KEY_Z)
|| (event.keyCode >= KeyCode.KEY_0 && event.keyCode <= KeyCode.KEY_9)
|| (event.keyCode >= KeyCode.NUMPAD_0 && event.keyCode <= KeyCode.NUMPAD_9)
|| (event.keyCode >= KeyCode.US_SEMICOLON && event.keyCode <= KeyCode.US_QUOTE);
}
};
class TypeLabelController<T> implements IDisposable {
@@ -347,7 +349,8 @@ class TypeLabelController<T> implements IDisposable {
constructor(
private list: List<T>,
private view: ListView<T>,
private keyboardNavigationLabelProvider: IKeyboardNavigationLabelProvider<T>
private keyboardNavigationLabelProvider: IKeyboardNavigationLabelProvider<T>,
private delegate: IKeyboardNavigationDelegate
) {
this.updateOptions(list.options);
}
@@ -379,7 +382,7 @@ class TypeLabelController<T> implements IDisposable {
.filter(e => !isInputElement(e.target as HTMLElement))
.filter(() => this.automaticKeyboardNavigation || this.triggered)
.map(event => new StandardKeyboardEvent(event))
.filter(this.keyboardNavigationLabelProvider.mightProducePrintableCharacter ? e => this.keyboardNavigationLabelProvider.mightProducePrintableCharacter!(e) : e => mightProducePrintableCharacter(e))
.filter(e => this.delegate.mightProducePrintableCharacter(e))
.forEach(e => { e.stopPropagation(); e.preventDefault(); })
.map(event => event.browserEvent.key)
.event;
@@ -818,6 +821,7 @@ export interface IListOptions<T> extends IListStyles {
readonly enableKeyboardNavigation?: boolean;
readonly automaticKeyboardNavigation?: boolean;
readonly keyboardNavigationLabelProvider?: IKeyboardNavigationLabelProvider<T>;
readonly keyboardNavigationDelegate?: IKeyboardNavigationDelegate;
readonly ariaRole?: ListAriaRootRole;
readonly ariaLabel?: string;
readonly keyboardSupport?: boolean;
@@ -1107,13 +1111,11 @@ export class List<T> implements ISpliceable<T>, IDisposable {
return Event.map(this.eventBufferer.wrapEvent(this.selection.onChange), e => this.toListEvent(e));
}
private _onDidOpen = new Emitter<IListEvent<T>>();
private readonly _onDidOpen = new Emitter<IListEvent<T>>();
readonly onDidOpen: Event<IListEvent<T>> = this._onDidOpen.event;
private _onPin = new Emitter<number[]>();
@memoize get onPin(): Event<IListEvent<T>> {
return Event.map(this._onPin.event, indexes => this.toListEvent({ indexes }));
}
private readonly _onDidPin = new Emitter<IListEvent<T>>();
readonly onDidPin: Event<IListEvent<T>> = this._onDidPin.event;
get domId(): string { return this.view.domId; }
get onDidScroll(): Event<ScrollEvent> { return this.view.onDidScroll; }
@@ -1166,7 +1168,7 @@ export class List<T> implements ISpliceable<T>, IDisposable {
readonly onDidFocus: Event<void>;
readonly onDidBlur: Event<void>;
private _onDidDispose = new Emitter<void>();
private readonly _onDidDispose = new Emitter<void>();
readonly onDidDispose: Event<void> = this._onDidDispose.event;
constructor(
@@ -1228,7 +1230,8 @@ export class List<T> implements ISpliceable<T>, IDisposable {
}
if (_options.keyboardNavigationLabelProvider) {
this.typeLabelController = new TypeLabelController(this, this.view, _options.keyboardNavigationLabelProvider);
const delegate = _options.keyboardNavigationDelegate || DefaultKeyboardNavigationDelegate;
this.typeLabelController = new TypeLabelController(this, this.view, _options.keyboardNavigationLabelProvider, delegate);
this.disposables.add(this.typeLabelController);
}
@@ -1582,14 +1585,14 @@ export class List<T> implements ISpliceable<T>, IDisposable {
this._onDidOpen.fire({ indexes, elements: indexes.map(i => this.view.element(i)), browserEvent });
}
pin(indexes: number[]): void {
pin(indexes: number[], browserEvent?: UIEvent): void {
for (const index of indexes) {
if (index < 0 || index >= this.length) {
throw new ListError(this.user, `Invalid index ${index}`);
}
}
this._onPin.fire(indexes);
this._onDidPin.fire({ indexes, elements: indexes.map(i => this.view.element(i)), browserEvent });
}
style(styles: IListStyles): void {
@@ -1626,7 +1629,7 @@ export class List<T> implements ISpliceable<T>, IDisposable {
this.disposables.dispose();
this._onDidOpen.dispose();
this._onPin.dispose();
this._onDidPin.dispose();
this._onDidDispose.dispose();
}
}

View File

@@ -39,8 +39,6 @@ class SelectListRenderer implements IListRenderer<ISelectOptionItem, ISelectList
get templateId(): string { return SELECT_OPTION_ENTRY_TEMPLATE_ID; }
constructor() { }
renderTemplate(container: HTMLElement): ISelectListTemplateData {
const data: ISelectListTemplateData = Object.create(null);
data.disposables = [];

View File

@@ -76,6 +76,9 @@
background-position: center center;
background-repeat: no-repeat;
margin-right: 0;
display: flex;
align-items: center;
justify-content: center;
}
/* Bold font style does not go well with CJK fonts */

View File

@@ -1,5 +0,0 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M4 8C4 8.19778 3.94135 8.39112 3.83147 8.55557C3.72159 8.72002 3.56541 8.84819 3.38268 8.92388C3.19996 8.99957 2.99889 9.01937 2.80491 8.98079C2.61093 8.9422 2.43275 8.84696 2.29289 8.70711C2.15304 8.56725 2.0578 8.38907 2.01922 8.19509C1.98063 8.00111 2.00043 7.80004 2.07612 7.61732C2.15181 7.43459 2.27998 7.27841 2.44443 7.16853C2.60888 7.05865 2.80222 7 3 7C3.26522 7 3.51957 7.10536 3.70711 7.29289C3.89464 7.48043 4 7.73478 4 8Z" fill="#C5C5C5"/>
<path d="M9 8C9 8.19778 8.94135 8.39112 8.83147 8.55557C8.72159 8.72002 8.56541 8.84819 8.38268 8.92388C8.19996 8.99957 7.99889 9.01937 7.80491 8.98079C7.61093 8.9422 7.43275 8.84696 7.29289 8.70711C7.15304 8.56725 7.0578 8.38907 7.01922 8.19509C6.98063 8.00111 7.00043 7.80004 7.07612 7.61732C7.15181 7.43459 7.27998 7.27841 7.44443 7.16853C7.60888 7.05865 7.80222 7 8 7C8.26522 7 8.51957 7.10536 8.70711 7.29289C8.89464 7.48043 9 7.73478 9 8Z" fill="#C5C5C5"/>
<path d="M14 8C14 8.19778 13.9414 8.39112 13.8315 8.55557C13.7216 8.72002 13.5654 8.84819 13.3827 8.92388C13.2 8.99957 12.9989 9.01937 12.8049 8.98079C12.6109 8.9422 12.4327 8.84696 12.2929 8.70711C12.153 8.56725 12.0578 8.38907 12.0192 8.19509C11.9806 8.00111 12.0004 7.80004 12.0761 7.61732C12.1518 7.43459 12.28 7.27841 12.4444 7.16853C12.6089 7.05865 12.8022 7 13 7C13.2652 7 13.5196 7.10536 13.7071 7.29289C13.8946 7.48043 14 7.73478 14 8Z" fill="#C5C5C5"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -1,5 +0,0 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M4 8C4 8.19778 3.94135 8.39112 3.83147 8.55557C3.72159 8.72002 3.56541 8.84819 3.38268 8.92388C3.19996 8.99957 2.99889 9.01937 2.80491 8.98079C2.61093 8.9422 2.43275 8.84696 2.29289 8.70711C2.15304 8.56725 2.0578 8.38907 2.01922 8.19509C1.98063 8.00111 2.00043 7.80004 2.07612 7.61732C2.15181 7.43459 2.27998 7.27841 2.44443 7.16853C2.60888 7.05865 2.80222 7 3 7C3.26522 7 3.51957 7.10536 3.70711 7.29289C3.89464 7.48043 4 7.73478 4 8Z" fill="white"/>
<path d="M9 8C9 8.19778 8.94135 8.39112 8.83147 8.55557C8.72159 8.72002 8.56541 8.84819 8.38268 8.92388C8.19996 8.99957 7.99889 9.01937 7.80491 8.98079C7.61093 8.9422 7.43275 8.84696 7.29289 8.70711C7.15304 8.56725 7.0578 8.38907 7.01922 8.19509C6.98063 8.00111 7.00043 7.80004 7.07612 7.61732C7.15181 7.43459 7.27998 7.27841 7.44443 7.16853C7.60888 7.05865 7.80222 7 8 7C8.26522 7 8.51957 7.10536 8.70711 7.29289C8.89464 7.48043 9 7.73478 9 8Z" fill="white"/>
<path d="M14 8C14 8.19778 13.9414 8.39112 13.8315 8.55557C13.7216 8.72002 13.5654 8.84819 13.3827 8.92388C13.2 8.99957 12.9989 9.01937 12.8049 8.98079C12.6109 8.9422 12.4327 8.84696 12.2929 8.70711C12.153 8.56725 12.0578 8.38907 12.0192 8.19509C11.9806 8.00111 12.0004 7.80004 12.0761 7.61732C12.1518 7.43459 12.28 7.27841 12.4444 7.16853C12.6089 7.05865 12.8022 7 13 7C13.2652 7 13.5196 7.10536 13.7071 7.29289C13.8946 7.48043 14 7.73478 14 8Z" fill="white"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -1,5 +0,0 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M4 8C4 8.19778 3.94135 8.39112 3.83147 8.55557C3.72159 8.72002 3.56541 8.84819 3.38268 8.92388C3.19996 8.99957 2.99889 9.01937 2.80491 8.98079C2.61093 8.9422 2.43275 8.84696 2.29289 8.70711C2.15304 8.56725 2.0578 8.38907 2.01922 8.19509C1.98063 8.00111 2.00043 7.80004 2.07612 7.61732C2.15181 7.43459 2.27998 7.27841 2.44443 7.16853C2.60888 7.05865 2.80222 7 3 7C3.26522 7 3.51957 7.10536 3.70711 7.29289C3.89464 7.48043 4 7.73478 4 8Z" fill="#424242"/>
<path d="M9 8C9 8.19778 8.94135 8.39112 8.83147 8.55557C8.72159 8.72002 8.56541 8.84819 8.38268 8.92388C8.19996 8.99957 7.99889 9.01937 7.80491 8.98079C7.61093 8.9422 7.43275 8.84696 7.29289 8.70711C7.15304 8.56725 7.0578 8.38907 7.01922 8.19509C6.98063 8.00111 7.00043 7.80004 7.07612 7.61732C7.15181 7.43459 7.27998 7.27841 7.44443 7.16853C7.60888 7.05865 7.80222 7 8 7C8.26522 7 8.51957 7.10536 8.70711 7.29289C8.89464 7.48043 9 7.73478 9 8Z" fill="#424242"/>
<path d="M14 8C14 8.19778 13.9414 8.39112 13.8315 8.55557C13.7216 8.72002 13.5654 8.84819 13.3827 8.92388C13.2 8.99957 12.9989 9.01937 12.8049 8.98079C12.6109 8.9422 12.4327 8.84696 12.2929 8.70711C12.153 8.56725 12.0578 8.38907 12.0192 8.19509C11.9806 8.00111 12.0004 7.80004 12.0761 7.61732C12.1518 7.43459 12.28 7.27841 12.4444 7.16853C12.6089 7.05865 12.8022 7 13 7C13.2652 7 13.5196 7.10536 13.7071 7.29289C13.8946 7.48043 14 7.73478 14 8Z" fill="#424242"/>
</svg>

Before

Width:  |  Height:  |  Size: 1.5 KiB

View File

@@ -7,15 +7,3 @@
display: inline-block;
padding: 0;
}
.vs .monaco-toolbar .action-label.toolbar-toggle-more {
background-image: url('ellipsis-light.svg');
}
.vs-dark .monaco-toolbar .action-label.toolbar-toggle-more {
background-image: url('ellipsis-dark.svg');
}
.hc-black .monaco-toolbar .action-label.toolbar-toggle-more {
background-image: url('ellipsis-hc.svg');
}

View File

@@ -65,7 +65,7 @@ export class ToolBar extends Disposable {
this.options.actionViewItemProvider,
this.actionRunner,
this.options.getKeyBinding,
'toolbar-toggle-more',
'codicon-more',
this.options.anchorAlignmentProvider
);
this.toggleMenuActionViewItem.value.setActionContext(this.actionBar.context);

View File

@@ -5,16 +5,16 @@
import 'vs/css!./media/tree';
import { IDisposable, dispose, Disposable, toDisposable, DisposableStore } from 'vs/base/common/lifecycle';
import { IListOptions, List, IListStyles, mightProducePrintableCharacter, MouseController } from 'vs/base/browser/ui/list/listWidget';
import { IListVirtualDelegate, IListRenderer, IListMouseEvent, IListEvent, IListContextMenuEvent, IListDragAndDrop, IListDragOverReaction, IKeyboardNavigationLabelProvider, IIdentityProvider } from 'vs/base/browser/ui/list/list';
import { IListOptions, List, IListStyles, MouseController, DefaultKeyboardNavigationDelegate } from 'vs/base/browser/ui/list/listWidget';
import { IListVirtualDelegate, IListRenderer, IListMouseEvent, IListEvent, IListContextMenuEvent, IListDragAndDrop, IListDragOverReaction, IKeyboardNavigationLabelProvider, IIdentityProvider, IKeyboardNavigationDelegate } from 'vs/base/browser/ui/list/list';
import { append, $, toggleClass, getDomNodePagePosition, removeClass, addClass, hasClass, hasParentWithClass, createStyleSheet, clearNode } from 'vs/base/browser/dom';
import { Event, Relay, Emitter, EventBufferer } from 'vs/base/common/event';
import { StandardKeyboardEvent, IKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
import { KeyCode } from 'vs/base/common/keyCodes';
import { ITreeModel, ITreeNode, ITreeRenderer, ITreeEvent, ITreeMouseEvent, ITreeContextMenuEvent, ITreeFilter, ITreeNavigator, ICollapseStateChangeEvent, ITreeDragAndDrop, TreeDragOverBubble, TreeVisibility, TreeFilterResult, ITreeModelSpliceEvent, TreeMouseEventTarget } from 'vs/base/browser/ui/tree/tree';
import { ISpliceable } from 'vs/base/common/sequence';
import { IDragAndDropData, StaticDND, DragAndDropData } from 'vs/base/browser/dnd';
import { range, equals, distinctES6 } from 'vs/base/common/arrays';
import { range, equals, distinctES6, fromSet } from 'vs/base/common/arrays';
import { ElementsDragAndDropData } from 'vs/base/browser/ui/list/listView';
import { domEvent } from 'vs/base/browser/event';
import { fuzzyScore, FuzzyScore } from 'vs/base/common/filters';
@@ -567,7 +567,7 @@ class TypeFilterController<T, TFilterData> implements IDisposable {
private _empty: boolean = false;
get empty(): boolean { return this._empty; }
private _onDidChangeEmptyState = new Emitter<boolean>();
private readonly _onDidChangeEmptyState = new Emitter<boolean>();
readonly onDidChangeEmptyState: Event<boolean> = Event.latch(this._onDidChangeEmptyState.event);
private positionClassName = 'ne';
@@ -581,7 +581,7 @@ class TypeFilterController<T, TFilterData> implements IDisposable {
private automaticKeyboardNavigation = true;
private triggered = false;
private _onDidChangePattern = new Emitter<string>();
private readonly _onDidChangePattern = new Emitter<string>();
readonly onDidChangePattern = this._onDidChangePattern.event;
private enabledDisposables: IDisposable[] = [];
@@ -592,7 +592,7 @@ class TypeFilterController<T, TFilterData> implements IDisposable {
model: ITreeModel<T, TFilterData, any>,
private view: List<ITreeNode<T, TFilterData>>,
private filter: TypeFilter<T>,
private keyboardNavigationLabelProvider: IKeyboardNavigationLabelProvider<T>
private keyboardNavigationDelegate: IKeyboardNavigationDelegate
) {
this.domNode = $(`.monaco-list-type-filter.${this.positionClassName}`);
this.domNode.draggable = true;
@@ -658,13 +658,12 @@ class TypeFilterController<T, TFilterData> implements IDisposable {
return;
}
const isPrintableCharEvent = this.keyboardNavigationLabelProvider.mightProducePrintableCharacter ? (e: IKeyboardEvent) => this.keyboardNavigationLabelProvider.mightProducePrintableCharacter!(e) : (e: IKeyboardEvent) => mightProducePrintableCharacter(e);
const onKeyDown = Event.chain(domEvent(this.view.getHTMLElement(), 'keydown'))
.filter(e => !isInputElement(e.target as HTMLElement) || e.target === this.filterOnTypeDomNode)
.map(e => new StandardKeyboardEvent(e))
.filter(this.keyboardNavigationEventFilter || (() => true))
.filter(() => this.automaticKeyboardNavigation || this.triggered)
.filter(e => isPrintableCharEvent(e) || ((this.pattern.length > 0 || this.triggered) && ((e.keyCode === KeyCode.Escape || e.keyCode === KeyCode.Backspace) && !e.altKey && !e.ctrlKey && !e.metaKey) || (e.keyCode === KeyCode.Backspace && (isMacintosh ? (e.altKey && !e.metaKey) : e.ctrlKey) && !e.shiftKey)))
.filter(e => this.keyboardNavigationDelegate.mightProducePrintableCharacter(e) || ((this.pattern.length > 0 || this.triggered) && ((e.keyCode === KeyCode.Escape || e.keyCode === KeyCode.Backspace) && !e.altKey && !e.ctrlKey && !e.metaKey) || (e.keyCode === KeyCode.Backspace && (isMacintosh ? (e.altKey && !e.metaKey) : e.ctrlKey) && !e.shiftKey)))
.forEach(e => { e.stopPropagation(); e.preventDefault(); })
.event;
@@ -935,7 +934,7 @@ class Trait<T> {
private nodes: ITreeNode<T, any>[] = [];
private elements: T[] | undefined;
private _onDidChange = new Emitter<ITreeEvent<T>>();
private readonly _onDidChange = new Emitter<ITreeEvent<T>>();
readonly onDidChange = this._onDidChange.event;
private _nodeSet: Set<ITreeNode<T, any>> | undefined;
@@ -1189,6 +1188,7 @@ export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable
get onDidChangeFocus(): Event<ITreeEvent<T>> { return this.eventBufferer.wrapEvent(this.focus.onDidChange); }
get onDidChangeSelection(): Event<ITreeEvent<T>> { return this.eventBufferer.wrapEvent(this.selection.onDidChange); }
get onDidOpen(): Event<ITreeEvent<T>> { return Event.map(this.view.onDidOpen, asTreeEvent); }
get onDidPin(): Event<ITreeEvent<T>> { return Event.map(this.view.onDidPin, asTreeEvent); }
get onMouseClick(): Event<ITreeMouseEvent<T>> { return Event.map(this.view.onMouseClick, asTreeMouseEvent); }
get onMouseDblClick(): Event<ITreeMouseEvent<T>> { return Event.map(this.view.onMouseDblClick, asTreeMouseEvent); }
@@ -1204,7 +1204,7 @@ export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable
get onDidChangeCollapseState(): Event<ICollapseStateChangeEvent<T, TFilterData>> { return this.model.onDidChangeCollapseState; }
get onDidChangeRenderNodeCount(): Event<ITreeNode<T, TFilterData>> { return this.model.onDidChangeRenderNodeCount; }
private _onWillRefilter = new Emitter<void>();
private readonly _onWillRefilter = new Emitter<void>();
readonly onWillRefilter: Event<void> = this._onWillRefilter.event;
get filterOnType(): boolean { return !!this._options.filterOnType; }
@@ -1213,7 +1213,7 @@ export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable
get openOnSingleClick(): boolean { return typeof this._options.openOnSingleClick === 'undefined' ? true : this._options.openOnSingleClick; }
get expandOnlyOnTwistieClick(): boolean | ((e: T) => boolean) { return typeof this._options.expandOnlyOnTwistieClick === 'undefined' ? false : this._options.expandOnlyOnTwistieClick; }
private _onDidUpdateOptions = new Emitter<IAbstractTreeOptions<T, TFilterData>>();
private readonly _onDidUpdateOptions = new Emitter<IAbstractTreeOptions<T, TFilterData>>();
readonly onDidUpdateOptions: Event<IAbstractTreeOptions<T, TFilterData>> = this._onDidUpdateOptions.event;
get onDidDispose(): Event<void> { return this.view.onDidDispose; }
@@ -1228,7 +1228,7 @@ export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable
const treeDelegate = new ComposedTreeDelegate<T, ITreeNode<T, TFilterData>>(delegate);
const onDidChangeCollapseStateRelay = new Relay<ICollapseStateChangeEvent<T, TFilterData>>();
const onDidChangeActiveNodes = new Relay<ITreeNode<T, TFilterData>[]>();
const onDidChangeActiveNodes = new Emitter<ITreeNode<T, TFilterData>[]>();
const activeNodes = new EventCollection(onDidChangeActiveNodes.event);
this.disposables.push(activeNodes);
@@ -1251,11 +1251,23 @@ export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable
onDidChangeCollapseStateRelay.input = this.model.onDidChangeCollapseState;
this.model.onDidSplice(e => {
this.focus.onDidModelSplice(e);
this.selection.onDidModelSplice(e);
}, null, this.disposables);
this.eventBufferer.bufferEvents(() => {
this.focus.onDidModelSplice(e);
this.selection.onDidModelSplice(e);
});
onDidChangeActiveNodes.input = Event.map(Event.any<any>(this.focus.onDidChange, this.selection.onDidChange, this.model.onDidSplice), () => [...this.focus.getNodes(), ...this.selection.getNodes()]);
const set = new Set<ITreeNode<T, TFilterData>>();
for (const node of this.focus.getNodes()) {
set.add(node);
}
for (const node of this.selection.getNodes()) {
set.add(node);
}
onDidChangeActiveNodes.fire(fromSet(set));
}, null, this.disposables);
if (_options.keyboardSupport !== false) {
const onKeyDown = Event.chain(this.view.onKeyDown)
@@ -1268,7 +1280,8 @@ export abstract class AbstractTree<T, TFilterData, TRef> implements IDisposable
}
if (_options.keyboardNavigationLabelProvider) {
this.typeFilterController = new TypeFilterController(this, this.model, this.view, filter!, _options.keyboardNavigationLabelProvider);
const delegate = _options.keyboardNavigationDelegate || DefaultKeyboardNavigationDelegate;
this.typeFilterController = new TypeFilterController(this, this.model, this.view, filter!, delegate);
this.focusNavigationFilter = node => this.typeFilterController!.shouldAllowFocus(node);
this.disposables.push(this.typeFilterController!);
}

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import { ComposedTreeDelegate, IAbstractTreeOptions, IAbstractTreeOptionsUpdate } from 'vs/base/browser/ui/tree/abstractTree';
import { ObjectTree, IObjectTreeOptions, CompressibleObjectTree, ICompressibleTreeRenderer } from 'vs/base/browser/ui/tree/objectTree';
import { ObjectTree, IObjectTreeOptions, CompressibleObjectTree, ICompressibleTreeRenderer, ICompressibleKeyboardNavigationLabelProvider, ICompressibleObjectTreeOptions } from 'vs/base/browser/ui/tree/objectTree';
import { IListVirtualDelegate, IIdentityProvider, IListDragAndDrop, IListDragOverReaction } from 'vs/base/browser/ui/list/list';
import { ITreeElement, ITreeNode, ITreeRenderer, ITreeEvent, ITreeMouseEvent, ITreeContextMenuEvent, ITreeSorter, ICollapseStateChangeEvent, IAsyncDataSource, ITreeDragAndDrop, TreeError, WeakMapper } from 'vs/base/browser/ui/tree/tree';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
@@ -1010,6 +1010,24 @@ export interface ITreeCompressionDelegate<T> {
isIncompressible(element: T): boolean;
}
function asCompressibleObjectTreeOptions<TInput, T, TFilterData>(options?: ICompressibleAsyncDataTreeOptions<T, TFilterData>): ICompressibleObjectTreeOptions<IAsyncDataTreeNode<TInput, T>, TFilterData> | undefined {
const objectTreeOptions = options && asObjectTreeOptions(options);
return objectTreeOptions && {
...objectTreeOptions,
keyboardNavigationLabelProvider: objectTreeOptions.keyboardNavigationLabelProvider && {
...objectTreeOptions.keyboardNavigationLabelProvider,
getCompressedNodeKeyboardNavigationLabel(els) {
return options!.keyboardNavigationLabelProvider!.getCompressedNodeKeyboardNavigationLabel(els.map(e => e.element as T));
}
}
};
}
export interface ICompressibleAsyncDataTreeOptions<T, TFilterData = void> extends IAsyncDataTreeOptions<T, TFilterData> {
readonly keyboardNavigationLabelProvider?: ICompressibleKeyboardNavigationLabelProvider<T>;
}
export class CompressibleAsyncDataTree<TInput, T, TFilterData = void> extends AsyncDataTree<TInput, T, TFilterData> {
protected readonly compressibleNodeMapper: CompressibleAsyncDataTreeNodeMapper<TInput, T, TFilterData> = new WeakMapper(node => new CompressibleAsyncDataTreeNodeWrapper(node));
@@ -1031,11 +1049,11 @@ export class CompressibleAsyncDataTree<TInput, T, TFilterData = void> extends As
container: HTMLElement,
delegate: IListVirtualDelegate<T>,
renderers: ICompressibleTreeRenderer<T, TFilterData, any>[],
options: IAsyncDataTreeOptions<T, TFilterData>
options: ICompressibleAsyncDataTreeOptions<T, TFilterData>
): ObjectTree<IAsyncDataTreeNode<TInput, T>, TFilterData> {
const objectTreeDelegate = new ComposedTreeDelegate<TInput | T, IAsyncDataTreeNode<TInput, T>>(delegate);
const objectTreeRenderers = renderers.map(r => new CompressibleAsyncDataTreeRenderer(r, this.nodeMapper, () => this.compressibleNodeMapper, this._onDidChangeNodeSlowState.event));
const objectTreeOptions = asObjectTreeOptions<TInput, T, TFilterData>(options) || {};
const objectTreeOptions = asCompressibleObjectTreeOptions<TInput, T, TFilterData>(options) || {};
return new CompressibleObjectTree(user, container, objectTreeDelegate, objectTreeRenderers, objectTreeOptions);
}

View File

@@ -336,7 +336,7 @@ function mapOptions<T, TFilterData>(compressedNodeUnwrapper: CompressedNodeUnwra
...options,
sorter: options.sorter && {
compare(node: ICompressedTreeNode<T>, otherNode: ICompressedTreeNode<T>): number {
return options.sorter!.compare(compressedNodeUnwrapper(node), compressedNodeUnwrapper(otherNode));
return options.sorter!.compare(node.elements[0], otherNode.elements[0]);
}
},
identityProvider: options.identityProvider && {

View File

@@ -162,9 +162,10 @@ export class DataTree<TInput, T, TFilterData = void> extends AbstractTree<T | nu
const children = this.dataSource.getChildren(element);
const elements = Iterator.map<any, ITreeElement<T>>(Iterator.fromArray(children), element => {
const { elements: children, size } = this.iterate(element, isCollapsed);
const collapsible = this.dataSource.hasChildren ? this.dataSource.hasChildren(element) : undefined;
const collapsed = size === 0 ? undefined : (isCollapsed && isCollapsed(element));
return { element, children, collapsed };
return { element, children, collapsible, collapsed };
});
return { elements, size: children.length };

View File

@@ -62,17 +62,17 @@ export class IndexTreeModel<T extends Exclude<any, undefined>, TFilterData = voi
private root: IIndexTreeNode<T, TFilterData>;
private eventBufferer = new EventBufferer();
private _onDidChangeCollapseState = new Emitter<ICollapseStateChangeEvent<T, TFilterData>>();
private readonly _onDidChangeCollapseState = new Emitter<ICollapseStateChangeEvent<T, TFilterData>>();
readonly onDidChangeCollapseState: Event<ICollapseStateChangeEvent<T, TFilterData>> = this.eventBufferer.wrapEvent(this._onDidChangeCollapseState.event);
private _onDidChangeRenderNodeCount = new Emitter<ITreeNode<T, TFilterData>>();
private readonly _onDidChangeRenderNodeCount = new Emitter<ITreeNode<T, TFilterData>>();
readonly onDidChangeRenderNodeCount: Event<ITreeNode<T, TFilterData>> = this.eventBufferer.wrapEvent(this._onDidChangeRenderNodeCount.event);
private collapseByDefault: boolean;
private filter?: ITreeFilter<T, TFilterData>;
private autoExpandSingleChildren: boolean;
private _onDidSplice = new Emitter<ITreeModelSpliceEvent<T, TFilterData>>();
private readonly _onDidSplice = new Emitter<ITreeModelSpliceEvent<T, TFilterData>>();
readonly onDidSplice = this._onDidSplice.event;
constructor(
@@ -169,7 +169,7 @@ export class IndexTreeModel<T extends Exclude<any, undefined>, TFilterData = voi
parentNode.visibleChildrenCount += insertedVisibleChildrenCount - deletedVisibleChildrenCount;
if (revealed && visible) {
const visibleDeleteCount = deletedNodes.reduce((r, node) => r + node.renderNodeCount, 0);
const visibleDeleteCount = deletedNodes.reduce((r, node) => r + (node.visible ? node.renderNodeCount : 0), 0);
this._updateAncestorsRenderNodeCount(parentNode, renderNodeCount - visibleDeleteCount);
this.list.splice(listIndex, visibleDeleteCount, treeListElementsToInsert);

View File

@@ -8,9 +8,10 @@ import { AbstractTree, IAbstractTreeOptions } from 'vs/base/browser/ui/tree/abst
import { ISpliceable } from 'vs/base/common/sequence';
import { ITreeNode, ITreeModel, ITreeElement, ITreeRenderer, ITreeSorter, ICollapseStateChangeEvent } from 'vs/base/browser/ui/tree/tree';
import { ObjectTreeModel, IObjectTreeModel } from 'vs/base/browser/ui/tree/objectTreeModel';
import { IListVirtualDelegate } from 'vs/base/browser/ui/list/list';
import { IListVirtualDelegate, IKeyboardNavigationLabelProvider } from 'vs/base/browser/ui/list/list';
import { Event } from 'vs/base/common/event';
import { CompressibleObjectTreeModel, ElementMapper, ICompressedTreeNode, ICompressedTreeElement } from 'vs/base/browser/ui/tree/compressedObjectTreeModel';
import { memoize } from 'vs/base/common/decorators';
export interface IObjectTreeOptions<T, TFilterData = void> extends IAbstractTreeOptions<T, TFilterData> {
sorter?: ITreeSorter<T>;
@@ -77,9 +78,12 @@ class CompressibleRenderer<T, TFilterData, TTemplateData> implements ITreeRender
readonly templateId: string;
readonly onDidChangeTwistieState: Event<T> | undefined;
compressedTreeNodeProvider: ICompressedTreeNodeProvider<T, TFilterData>;
@memoize
private get compressedTreeNodeProvider(): ICompressedTreeNodeProvider<T, TFilterData> {
return this._compressedTreeNodeProvider();
}
constructor(private renderer: ICompressibleTreeRenderer<T, TFilterData, TTemplateData>) {
constructor(private _compressedTreeNodeProvider: () => ICompressedTreeNodeProvider<T, TFilterData>, private renderer: ICompressibleTreeRenderer<T, TFilterData, TTemplateData>) {
this.templateId = renderer.templateId;
if (renderer.onDidChangeTwistieState) {
@@ -127,7 +131,38 @@ class CompressibleRenderer<T, TFilterData, TTemplateData> implements ITreeRender
}
}
export class CompressibleObjectTree<T extends NonNullable<any>, TFilterData = void> extends ObjectTree<T, TFilterData> {
export interface ICompressibleKeyboardNavigationLabelProvider<T> extends IKeyboardNavigationLabelProvider<T> {
getCompressedNodeKeyboardNavigationLabel(elements: T[]): { toString(): string | undefined; } | undefined;
}
export interface ICompressibleObjectTreeOptions<T, TFilterData = void> extends IObjectTreeOptions<T, TFilterData> {
readonly keyboardNavigationLabelProvider?: ICompressibleKeyboardNavigationLabelProvider<T>;
}
function asObjectTreeOptions<T, TFilterData>(compressedTreeNodeProvider: () => ICompressedTreeNodeProvider<T, TFilterData>, options?: ICompressibleObjectTreeOptions<T, TFilterData>): IObjectTreeOptions<T, TFilterData> | undefined {
return options && {
...options,
keyboardNavigationLabelProvider: options.keyboardNavigationLabelProvider && {
getKeyboardNavigationLabel(e: T) {
let compressedTreeNode: ITreeNode<ICompressedTreeNode<T>, TFilterData>;
try {
compressedTreeNode = compressedTreeNodeProvider().getCompressedTreeNode(e);
} catch {
return options.keyboardNavigationLabelProvider!.getKeyboardNavigationLabel(e);
}
if (compressedTreeNode.element.elements.length === 1) {
return options.keyboardNavigationLabelProvider!.getKeyboardNavigationLabel(e);
} else {
return options.keyboardNavigationLabelProvider!.getCompressedNodeKeyboardNavigationLabel(compressedTreeNode.element.elements);
}
}
}
};
}
export class CompressibleObjectTree<T extends NonNullable<any>, TFilterData = void> extends ObjectTree<T, TFilterData> implements ICompressedTreeNodeProvider<T, TFilterData> {
protected model: CompressibleObjectTreeModel<T, TFilterData>;
@@ -136,11 +171,11 @@ export class CompressibleObjectTree<T extends NonNullable<any>, TFilterData = vo
container: HTMLElement,
delegate: IListVirtualDelegate<T>,
renderers: ICompressibleTreeRenderer<T, TFilterData, any>[],
options: IObjectTreeOptions<T, TFilterData> = {}
options: ICompressibleObjectTreeOptions<T, TFilterData> = {}
) {
const compressibleRenderers = renderers.map(r => new CompressibleRenderer(r));
super(user, container, delegate, compressibleRenderers, options);
compressibleRenderers.forEach(r => r.compressedTreeNodeProvider = this);
const compressedTreeNodeProvider = () => this;
const compressibleRenderers = renderers.map(r => new CompressibleRenderer(compressedTreeNodeProvider, r));
super(user, container, delegate, compressibleRenderers, asObjectTreeOptions(compressedTreeNodeProvider, options));
}
setChildren(element: T | null, children?: ISequence<ICompressedTreeElement<T>>): void {

View File

@@ -9,6 +9,7 @@ import { IndexTreeModel, IIndexTreeModelOptions } from 'vs/base/browser/ui/tree/
import { Event } from 'vs/base/common/event';
import { ITreeModel, ITreeNode, ITreeElement, ITreeSorter, ICollapseStateChangeEvent, ITreeModelSpliceEvent, TreeError } from 'vs/base/browser/ui/tree/tree';
import { IIdentityProvider } from 'vs/base/browser/ui/list/list';
import { mergeSort } from 'vs/base/common/arrays';
export type ITreeNodeCallback<T, TFilterData> = (node: ITreeNode<T, TFilterData>) => void;
@@ -123,7 +124,7 @@ export class ObjectTreeModel<T extends NonNullable<any>, TFilterData extends Non
let iterator = elements ? getSequenceIterator(elements) : Iterator.empty<ITreeElement<T>>();
if (this.sorter) {
iterator = Iterator.fromArray(Iterator.collect(iterator).sort(this.sorter.compare.bind(this.sorter)));
iterator = Iterator.fromArray(mergeSort(Iterator.collect(iterator), this.sorter.compare.bind(this.sorter)));
}
return Iterator.map(iterator, treeElement => {

View File

@@ -164,6 +164,7 @@ export interface ITreeNavigator<T> {
}
export interface IDataSource<TInput, T> {
hasChildren?(element: TInput | T): boolean;
getChildren(element: TInput | T): T[];
}

View File

@@ -22,4 +22,4 @@ export class CollapseAllAction<TInput, T, TFilterData = void> extends Action {
return Promise.resolve();
}
}
}

View File

@@ -11,6 +11,7 @@ export function getPathFromAmdModule(requirefn: typeof require, relativePath: st
/**
* Reference a resource that might be inlined.
* Do not inline icons that will be used by the native mac touchbar.
* Do not rename this method unless you adopt the build scripts.
*/
export function registerAndGetAmdImageURL(absolutePath: string): string {

View File

@@ -372,6 +372,12 @@ export function distinctES6<T>(array: ReadonlyArray<T>): T[] {
});
}
export function fromSet<T>(set: Set<T>): T[] {
const result: T[] = [];
set.forEach(o => result.push(o));
return result;
}
export function uniqueFilter<T>(keyFn: (t: T) => string): (t: T) => boolean {
const seen: { [key: string]: boolean; } = Object.create(null);
@@ -418,6 +424,12 @@ export function first<T>(array: ReadonlyArray<T>, fn: (item: T) => boolean, notF
return index < 0 ? notFoundValue : array[index];
}
export function firstOrDefault<T, NotFound = T>(array: ReadonlyArray<T>, notFoundValue: NotFound): T | NotFound;
export function firstOrDefault<T>(array: ReadonlyArray<T>): T | undefined;
export function firstOrDefault<T, NotFound = T>(array: ReadonlyArray<T>, notFoundValue?: NotFound): T | NotFound | undefined {
return array.length > 0 ? array[0] : notFoundValue;
}
export function commonPrefixLength<T>(one: ReadonlyArray<T>, other: ReadonlyArray<T>, equals: (a: T, b: T) => boolean = (a, b) => a === b): number {
let result = 0;

View File

@@ -97,6 +97,12 @@ export function fromMap<T>(original: Map<string, T>): IStringDictionary<T> {
return result;
}
export function mapValues<V>(map: Map<any, V>): V[] {
const result: V[] = [];
map.forEach(v => result.push(v));
return result;
}
export class SetMap<K, V> {
private map = new Map<K, Set<V>>();

View File

@@ -24,40 +24,64 @@ export function createDecorator(mapFn: (fn: Function, key: string) => Function):
};
}
export function memoize(target: any, key: string, descriptor: any) {
let fnKey: string | null = null;
let fn: Function | null = null;
let memoizeId = 0;
export function createMemoizer() {
const memoizeKeyPrefix = `$memoize${memoizeId++}`;
let self: any = undefined;
if (typeof descriptor.value === 'function') {
fnKey = 'value';
fn = descriptor.value;
const result = function memoize(target: any, key: string, descriptor: any) {
let fnKey: string | null = null;
let fn: Function | null = null;
if (fn!.length !== 0) {
console.warn('Memoize should only be used in functions with zero parameters');
}
} else if (typeof descriptor.get === 'function') {
fnKey = 'get';
fn = descriptor.get;
}
if (typeof descriptor.value === 'function') {
fnKey = 'value';
fn = descriptor.value;
if (!fn) {
throw new Error('not supported');
}
const memoizeKey = `$memoize$${key}`;
descriptor[fnKey!] = function (...args: any[]) {
if (!this.hasOwnProperty(memoizeKey)) {
Object.defineProperty(this, memoizeKey, {
configurable: false,
enumerable: false,
writable: false,
value: fn!.apply(this, args)
});
if (fn!.length !== 0) {
console.warn('Memoize should only be used in functions with zero parameters');
}
} else if (typeof descriptor.get === 'function') {
fnKey = 'get';
fn = descriptor.get;
}
return this[memoizeKey];
if (!fn) {
throw new Error('not supported');
}
const memoizeKey = `${memoizeKeyPrefix}:${key}`;
descriptor[fnKey!] = function (...args: any[]) {
self = this;
if (!this.hasOwnProperty(memoizeKey)) {
Object.defineProperty(this, memoizeKey, {
configurable: true,
enumerable: false,
writable: true,
value: fn!.apply(this, args)
});
}
return this[memoizeKey];
};
};
result.clear = () => {
if (typeof self === 'undefined') {
return;
}
Object.getOwnPropertyNames(self).forEach(property => {
if (property.indexOf(memoizeKeyPrefix) === 0) {
delete self[property];
}
});
};
return result;
}
export function memoize(target: any, key: string, descriptor: any) {
return createMemoizer()(target, key, descriptor);
}
export interface IDebouceReducer<T> {
@@ -87,4 +111,4 @@ export function debounce<T>(delay: number, reducer?: IDebouceReducer<T>, initial
}, delay);
};
});
}
}

View File

@@ -451,7 +451,7 @@ class LeakageMonitor {
* Sample:
class Document {
private _onDidChange = new Emitter<(value:string)=>any>();
private readonly _onDidChange = new Emitter<(value:string)=>any>();
public onDidChange = this._onDidChange.event;
@@ -808,7 +808,7 @@ export class Relay<T> implements IDisposable {
private inputEvent: Event<T> = Event.None;
private inputEventListener: IDisposable = Disposable.None;
private emitter = new Emitter<T>({
private readonly emitter = new Emitter<T>({
onFirstListenerDidAdd: () => {
this.listening = true;
this.inputEventListener = this.inputEvent(this.emitter.fire, this.emitter);

View File

@@ -11,7 +11,7 @@ export class HistoryNavigator<T> implements INavigator<T> {
private _limit: number;
private _navigator!: ArrayNavigator<T>;
constructor(history: T[] = [], limit: number = 10) {
constructor(history: readonly T[] = [], limit: number = 10) {
this._initialize(history);
this._limit = limit;
this._onChange();
@@ -62,7 +62,8 @@ export class HistoryNavigator<T> implements INavigator<T> {
private _onChange() {
this._reduceToLimit();
this._navigator = new ArrayNavigator(this._elements, 0, this._elements.length, this._elements.length);
const elements = this._elements;
this._navigator = new ArrayNavigator(elements, 0, elements.length, elements.length);
}
private _reduceToLimit() {
@@ -72,7 +73,7 @@ export class HistoryNavigator<T> implements INavigator<T> {
}
}
private _initialize(history: T[]): void {
private _initialize(history: readonly T[]): void {
this._history = new Set();
for (const entry of history) {
this._history.add(entry);

View File

@@ -18,6 +18,22 @@ export interface Iterator<T> {
next(): IteratorResult<T>;
}
interface NativeIteratorYieldResult<TYield> {
done?: false;
value: TYield;
}
interface NativeIteratorReturnResult<TReturn> {
done: true;
value: TReturn;
}
type NativeIteratorResult<T, TReturn = any> = NativeIteratorYieldResult<T> | NativeIteratorReturnResult<TReturn>;
export interface NativeIterator<T> {
next(): NativeIteratorResult<T>;
}
export module Iterator {
const _empty: Iterator<any> = {
next() {
@@ -56,6 +72,20 @@ export module Iterator {
};
}
export function fromNativeIterator<T>(it: NativeIterator<T>): Iterator<T> {
return {
next(): IteratorResult<T> {
const result = it.next();
if (result.done) {
return FIN;
}
return { done: false, value: result.value };
}
};
}
export function from<T>(elements: Iterator<T> | T[] | undefined): Iterator<T> {
if (!elements) {
return Iterator.empty();
@@ -160,12 +190,12 @@ export interface INextIterator<T> {
export class ArrayIterator<T> implements INextIterator<T> {
private items: T[];
private readonly items: readonly T[];
protected start: number;
protected end: number;
protected index: number;
constructor(items: T[], start: number = 0, end: number = items.length, index = start - 1) {
constructor(items: readonly T[], start: number = 0, end: number = items.length, index = start - 1) {
this.items = items;
this.start = start;
this.end = end;
@@ -193,7 +223,7 @@ export class ArrayIterator<T> implements INextIterator<T> {
export class ArrayNavigator<T> extends ArrayIterator<T> implements INavigator<T> {
constructor(items: T[], start: number = 0, end: number = items.length, index = start - 1) {
constructor(items: readonly T[], start: number = 0, end: number = items.length, index = start - 1) {
super(items, start, end, index);
}

View File

@@ -61,7 +61,7 @@ export interface IJSONSchema {
markdownDescription?: string; // VSCode extension
doNotSuggest?: boolean; // VSCode extension
allowComments?: boolean; // VSCode extension
allowsTrailingCommas?: boolean; // VSCode extension
allowTrailingCommas?: boolean; // VSCode extension
}
export interface IJSONSchemaMap {

View File

@@ -0,0 +1,191 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { memoize } from 'vs/base/common/decorators';
import * as paths from 'vs/base/common/path';
import { Iterator } from 'vs/base/common/iterator';
import { relativePath, joinPath } from 'vs/base/common/resources';
import { URI } from 'vs/base/common/uri';
import { mapValues } from 'vs/base/common/collections';
export interface ILeafNode<T, C = void> {
readonly uri: URI;
readonly relativePath: string;
readonly name: string;
readonly element: T;
readonly context: C;
}
export interface IBranchNode<T, C = void> {
readonly uri: URI;
readonly relativePath: string;
readonly name: string;
readonly size: number;
readonly children: Iterator<INode<T, C>>;
readonly parent: IBranchNode<T, C> | undefined;
readonly context: C;
get(childName: string): INode<T, C> | undefined;
}
export type INode<T, C> = IBranchNode<T, C> | ILeafNode<T, C>;
// Internals
class Node<C> {
@memoize
get name(): string { return paths.posix.basename(this.relativePath); }
constructor(readonly uri: URI, readonly relativePath: string, readonly context: C) { }
}
class BranchNode<T, C> extends Node<C> implements IBranchNode<T, C> {
private _children = new Map<string, BranchNode<T, C> | LeafNode<T, C>>();
get size(): number {
return this._children.size;
}
get children(): Iterator<BranchNode<T, C> | LeafNode<T, C>> {
return Iterator.fromArray(mapValues(this._children));
}
constructor(uri: URI, relativePath: string, context: C, readonly parent: IBranchNode<T, C> | undefined = undefined) {
super(uri, relativePath, context);
}
get(path: string): BranchNode<T, C> | LeafNode<T, C> | undefined {
return this._children.get(path);
}
set(path: string, child: BranchNode<T, C> | LeafNode<T, C>): void {
this._children.set(path, child);
}
delete(path: string): void {
this._children.delete(path);
}
}
class LeafNode<T, C> extends Node<C> implements ILeafNode<T, C> {
constructor(uri: URI, path: string, context: C, readonly element: T) {
super(uri, path, context);
}
}
function collect<T, C>(node: INode<T, C>, result: T[]): T[] {
if (ResourceTree.isBranchNode(node)) {
Iterator.forEach(node.children, child => collect(child, result));
} else {
result.push(node.element);
}
return result;
}
export class ResourceTree<T extends NonNullable<any>, C> {
readonly root: BranchNode<T, C>;
static isBranchNode<T, C>(obj: any): obj is IBranchNode<T, C> {
return obj instanceof BranchNode;
}
static getRoot<T, C>(node: IBranchNode<T, C>): IBranchNode<T, C> {
while (node.parent) {
node = node.parent;
}
return node;
}
static collect<T, C>(node: INode<T, C>): T[] {
return collect(node, []);
}
constructor(context: C, rootURI: URI = URI.file('/')) {
this.root = new BranchNode(rootURI, '', context);
}
add(uri: URI, element: T): void {
const key = relativePath(this.root.uri, uri) || uri.fsPath;
const parts = key.split(/[\\\/]/).filter(p => !!p);
let node = this.root;
let path = '';
for (let i = 0; i < parts.length; i++) {
const name = parts[i];
path = path + '/' + name;
let child = node.get(name);
if (!child) {
if (i < parts.length - 1) {
child = new BranchNode(joinPath(this.root.uri, path), path, this.root.context, node);
node.set(name, child);
} else {
child = new LeafNode(uri, path, this.root.context, element);
node.set(name, child);
return;
}
}
if (!(child instanceof BranchNode)) {
if (i < parts.length - 1) {
throw new Error('Inconsistent tree: can\'t override leaf with branch.');
}
// replace
node.set(name, new LeafNode(uri, path, this.root.context, element));
return;
} else if (i === parts.length - 1) {
throw new Error('Inconsistent tree: can\'t override branch with leaf.');
}
node = child;
}
}
delete(uri: URI): T | undefined {
const key = relativePath(this.root.uri, uri) || uri.fsPath;
const parts = key.split(/[\\\/]/).filter(p => !!p);
return this._delete(this.root, parts, 0);
}
private _delete(node: BranchNode<T, C>, parts: string[], index: number): T | undefined {
const name = parts[index];
const child = node.get(name);
if (!child) {
return undefined;
}
// not at end
if (index < parts.length - 1) {
if (child instanceof BranchNode) {
const result = this._delete(child, parts, index + 1);
if (typeof result !== 'undefined' && child.size === 0) {
node.delete(name);
}
return result;
} else {
throw new Error('Inconsistent tree: Expected a branch, found a leaf instead.');
}
}
//at end
if (child instanceof BranchNode) {
// TODO: maybe we can allow this
throw new Error('Inconsistent tree: Expected a leaf, found a branch instead.');
}
node.delete(name);
return child.element;
}
}

View File

@@ -24,11 +24,11 @@ export class Sequence<T> implements ISequence<T>, ISpliceable<T> {
readonly elements: T[] = [];
private _onDidSplice = new Emitter<ISplice<T>>();
private readonly _onDidSplice = new Emitter<ISplice<T>>();
readonly onDidSplice: Event<ISplice<T>> = this._onDidSplice.event;
splice(start: number, deleteCount: number, toInsert: T[] = []): void {
this.elements.splice(start, deleteCount, ...toInsert);
this._onDidSplice.fire({ start, deleteCount, toInsert });
}
}
}

View File

@@ -3,11 +3,11 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Menu, MenuItem, BrowserWindow, ipcMain } from 'electron';
import { Menu, MenuItem, BrowserWindow, ipcMain, IpcMainEvent } from 'electron';
import { ISerializableContextMenuItem, CONTEXT_MENU_CLOSE_CHANNEL, CONTEXT_MENU_CHANNEL, IPopupOptions } from 'vs/base/parts/contextmenu/common/contextmenu';
export function registerContextMenuListener(): void {
ipcMain.on(CONTEXT_MENU_CHANNEL, (event: Electron.IpcMainEvent, contextMenuId: number, items: ISerializableContextMenuItem[], onClickChannel: string, options?: IPopupOptions) => {
ipcMain.on(CONTEXT_MENU_CHANNEL, (event: IpcMainEvent, contextMenuId: number, items: ISerializableContextMenuItem[], onClickChannel: string, options?: IPopupOptions) => {
const menu = createMenu(event, onClickChannel, items);
menu.popup({
@@ -27,7 +27,7 @@ export function registerContextMenuListener(): void {
});
}
function createMenu(event: Electron.IpcMainEvent, onClickChannel: string, items: ISerializableContextMenuItem[]): Menu {
function createMenu(event: IpcMainEvent, onClickChannel: string, items: ISerializableContextMenuItem[]): Menu {
const menu = new Menu();
items.forEach(item => {
@@ -65,4 +65,4 @@ function createMenu(event: Electron.IpcMainEvent, onClickChannel: string, items:
});
return menu;
}
}

View File

@@ -150,6 +150,10 @@ export const enum ProtocolConstants {
* If there is no reconnection within this time-frame, consider the connection permanently closed...
*/
ReconnectionGraceTime = 3 * 60 * 60 * 1000, // 3hrs
/**
* Maximal grace time between the first and the last reconnection...
*/
ReconnectionShortGraceTime = 5 * 60 * 1000, // 5min
}
class ProtocolMessage {
@@ -347,10 +351,10 @@ export class Protocol extends Disposable implements IMessagePassingProtocol {
private _socketWriter: ProtocolWriter;
private _socketReader: ProtocolReader;
private _onMessage = new Emitter<VSBuffer>();
private readonly _onMessage = new Emitter<VSBuffer>();
readonly onMessage: Event<VSBuffer> = this._onMessage.event;
private _onClose = new Emitter<void>();
private readonly _onClose = new Emitter<void>();
readonly onClose: Event<void> = this._onClose.event;
constructor(socket: ISocket) {

View File

@@ -442,7 +442,7 @@ export class ChannelClient implements IChannelClient, IDisposable {
private lastRequestId: number = 0;
private protocolListener: IDisposable | null;
private _onDidInitialize = new Emitter<void>();
private readonly _onDidInitialize = new Emitter<void>();
readonly onDidInitialize = this._onDidInitialize.event;
constructor(private protocol: IMessagePassingProtocol) {
@@ -660,7 +660,7 @@ export class IPCServer<TContext = string> implements IChannelServer<TContext>, I
private channels = new Map<string, IServerChannel<TContext>>();
private _connections = new Set<Connection<TContext>>();
private _onDidChangeConnections = new Emitter<Connection<TContext>>();
private readonly _onDidChangeConnections = new Emitter<Connection<TContext>>();
readonly onDidChangeConnections: Event<Connection<TContext>> = this._onDidChangeConnections.event;
get connections(): Connection<TContext>[] {

View File

@@ -6,12 +6,12 @@
import { Event, Emitter } from 'vs/base/common/event';
import { IPCServer, ClientConnectionEvent } from 'vs/base/parts/ipc/common/ipc';
import { Protocol } from 'vs/base/parts/ipc/node/ipc.electron';
import { ipcMain } from 'electron';
import { ipcMain, WebContents } from 'electron';
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
import { VSBuffer } from 'vs/base/common/buffer';
interface IIPCEvent {
event: { sender: Electron.WebContents; };
event: { sender: WebContents; };
message: Buffer | null;
}
@@ -27,7 +27,7 @@ export class Server extends IPCServer {
private static Clients = new Map<number, IDisposable>();
private static getOnDidClientConnect(): Event<ClientConnectionEvent> {
const onHello = Event.fromNodeEventEmitter<Electron.WebContents>(ipcMain, 'ipc:hello', ({ sender }) => sender);
const onHello = Event.fromNodeEventEmitter<WebContents>(ipcMain, 'ipc:hello', ({ sender }) => sender);
return Event.map(onHello, webContents => {
const id = webContents.id;

View File

@@ -92,7 +92,7 @@ export class Client implements IChannelClient, IDisposable {
private _client: IPCClient | null;
private channels = new Map<string, IChannel>();
private _onDidProcessExit = new Emitter<{ code: number, signal: string }>();
private readonly _onDidProcessExit = new Emitter<{ code: number, signal: string }>();
readonly onDidProcessExit = this._onDidProcessExit.event;
constructor(private modulePath: string, private options: IIPCOptions) {

View File

@@ -16,7 +16,7 @@ class QueueProtocol implements IMessagePassingProtocol {
private buffering = true;
private buffers: VSBuffer[] = [];
private _onMessage = new Emitter<VSBuffer>({
private readonly _onMessage = new Emitter<VSBuffer>({
onFirstListenerDidAdd: () => {
for (const buffer of this.buffers) {
this._onMessage.fire(buffer);
@@ -57,7 +57,7 @@ function createProtocolPair(): [IMessagePassingProtocol, IMessagePassingProtocol
class TestIPCClient extends IPCClient<string> {
private _onDidDisconnect = new Emitter<void>();
private readonly _onDidDisconnect = new Emitter<void>();
readonly onDidDisconnect = this._onDidDisconnect.event;
constructor(protocol: IMessagePassingProtocol, id: string) {
@@ -107,7 +107,7 @@ interface ITestService {
class TestService implements ITestService {
private _pong = new Emitter<string>();
private readonly _pong = new Emitter<string>();
readonly pong = this._pong.event;
marco(): Promise<string> {

View File

@@ -20,7 +20,7 @@ export interface ITestService {
export class TestService implements ITestService {
private _onMarco = new Emitter<IMarcoPoloEvent>();
private readonly _onMarco = new Emitter<IMarcoPoloEvent>();
onMarco: Event<IMarcoPoloEvent> = this._onMarco.event;
marco(): Promise<string> {
@@ -76,4 +76,4 @@ export class TestServiceClient implements ITestService {
cancelMe(): Promise<boolean> {
return this.channel.call('cancelMe');
}
}
}

View File

@@ -101,7 +101,7 @@ suite('Storage Library', () => {
await mkdirp(storageDir);
class TestSQLiteStorageDatabase extends SQLiteStorageDatabase {
private _onDidChangeItemsExternal = new Emitter<IStorageItemsChangeEvent>();
private readonly _onDidChangeItemsExternal = new Emitter<IStorageItemsChangeEvent>();
get onDidChangeItemsExternal(): Event<IStorageItemsChangeEvent> { return this._onDidChangeItemsExternal.event; }
fireDidChangeItemsExternal(event: IStorageItemsChangeEvent): void {

View File

@@ -77,7 +77,7 @@ export class Tree implements _.ITree {
readonly onDidExpandItem: Event<Model.IItemExpandEvent> = this._onDidExpandItem.event;
private _onDidCollapseItem = new Relay<Model.IItemCollapseEvent>();
readonly onDidCollapseItem: Event<Model.IItemCollapseEvent> = this._onDidCollapseItem.event;
private _onDispose = new Emitter<void>();
private readonly _onDispose = new Emitter<void>();
readonly onDidDispose: Event<void> = this._onDispose.event;
constructor(container: HTMLElement, configuration: _.ITreeConfiguration, options: _.ITreeOptions = {}) {

View File

@@ -259,29 +259,29 @@ export class Item {
private traits: { [trait: string]: boolean; };
private _onDidCreate = new Emitter<Item>();
private readonly _onDidCreate = new Emitter<Item>();
readonly onDidCreate: Event<Item> = this._onDidCreate.event;
private _onDidReveal = new Emitter<IItemRevealEvent>();
private readonly _onDidReveal = new Emitter<IItemRevealEvent>();
readonly onDidReveal: Event<IItemRevealEvent> = this._onDidReveal.event;
private _onExpand = new Emitter<IItemExpandEvent>();
private readonly _onExpand = new Emitter<IItemExpandEvent>();
readonly onExpand: Event<IItemExpandEvent> = this._onExpand.event;
private _onDidExpand = new Emitter<IItemExpandEvent>();
private readonly _onDidExpand = new Emitter<IItemExpandEvent>();
readonly onDidExpand: Event<IItemExpandEvent> = this._onDidExpand.event;
private _onCollapse = new Emitter<IItemCollapseEvent>();
private readonly _onCollapse = new Emitter<IItemCollapseEvent>();
readonly onCollapse: Event<IItemCollapseEvent> = this._onCollapse.event;
private _onDidCollapse = new Emitter<IItemCollapseEvent>();
private readonly _onDidCollapse = new Emitter<IItemCollapseEvent>();
readonly onDidCollapse: Event<IItemCollapseEvent> = this._onDidCollapse.event;
private _onDidAddTrait = new Emitter<IItemTraitEvent>();
private readonly _onDidAddTrait = new Emitter<IItemTraitEvent>();
readonly onDidAddTrait: Event<IItemTraitEvent> = this._onDidAddTrait.event;
private _onDidRemoveTrait = new Emitter<IItemCollapseEvent>();
private readonly _onDidRemoveTrait = new Emitter<IItemCollapseEvent>();
readonly onDidRemoveTrait: Event<IItemCollapseEvent> = this._onDidRemoveTrait.event;
private _onDidRefresh = new Emitter<Item>();
private readonly _onDidRefresh = new Emitter<Item>();
readonly onDidRefresh: Event<Item> = this._onDidRefresh.event;
private _onRefreshChildren = new Emitter<IItemChildrenRefreshEvent>();
private readonly _onRefreshChildren = new Emitter<IItemChildrenRefreshEvent>();
readonly onRefreshChildren: Event<IItemChildrenRefreshEvent> = this._onRefreshChildren.event;
private _onDidRefreshChildren = new Emitter<IItemChildrenRefreshEvent>();
private readonly _onDidRefreshChildren = new Emitter<IItemChildrenRefreshEvent>();
readonly onDidRefreshChildren: Event<IItemChildrenRefreshEvent> = this._onDidRefreshChildren.event;
private _onDidDispose = new Emitter<Item>();
private readonly _onDidDispose = new Emitter<Item>();
readonly onDidDispose: Event<Item> = this._onDidDispose.event;
private _isDisposed: boolean;
@@ -868,19 +868,19 @@ export class TreeModel {
private registryDisposable: IDisposable = Disposable.None;
private traitsToItems: ITraitMap;
private _onSetInput = new Emitter<IInputEvent>();
private readonly _onSetInput = new Emitter<IInputEvent>();
readonly onSetInput: Event<IInputEvent> = this._onSetInput.event;
private _onDidSetInput = new Emitter<IInputEvent>();
private readonly _onDidSetInput = new Emitter<IInputEvent>();
readonly onDidSetInput: Event<IInputEvent> = this._onDidSetInput.event;
private _onRefresh = new Emitter<IRefreshEvent>();
private readonly _onRefresh = new Emitter<IRefreshEvent>();
readonly onRefresh: Event<IRefreshEvent> = this._onRefresh.event;
private _onDidRefresh = new Emitter<IRefreshEvent>();
private readonly _onDidRefresh = new Emitter<IRefreshEvent>();
readonly onDidRefresh: Event<IRefreshEvent> = this._onDidRefresh.event;
private _onDidHighlight = new Emitter<_.IHighlightEvent>();
private readonly _onDidHighlight = new Emitter<_.IHighlightEvent>();
readonly onDidHighlight: Event<_.IHighlightEvent> = this._onDidHighlight.event;
private _onDidSelect = new Emitter<_.ISelectionEvent>();
private readonly _onDidSelect = new Emitter<_.ISelectionEvent>();
readonly onDidSelect: Event<_.ISelectionEvent> = this._onDidSelect.event;
private _onDidFocus = new Emitter<_.IFocusEvent>();
private readonly _onDidFocus = new Emitter<_.IFocusEvent>();
readonly onDidFocus: Event<_.IFocusEvent> = this._onDidFocus.event;
private _onDidRevealItem = new Relay<IItemRevealEvent>();

View File

@@ -1081,10 +1081,10 @@ class DynamicModel implements _.IDataSource {
private data: any;
public promiseFactory: { (): Promise<any>; } | null;
private _onGetChildren = new Emitter<any>();
private readonly _onGetChildren = new Emitter<any>();
readonly onGetChildren: Event<any> = this._onGetChildren.event;
private _onDidGetChildren = new Emitter<any>();
private readonly _onDidGetChildren = new Emitter<any>();
readonly onDidGetChildren: Event<any> = this._onDidGetChildren.event;
constructor() {

View File

@@ -10,7 +10,7 @@ import { IView } from 'vs/base/browser/ui/grid/grid';
export class TestView implements IView {
private _onDidChange = new Emitter<{ width: number; height: number; } | undefined>();
private readonly _onDidChange = new Emitter<{ width: number; height: number; } | undefined>();
readonly onDidChange = this._onDidChange.event;
get minimumWidth(): number { return this._minimumWidth; }
@@ -28,7 +28,7 @@ export class TestView implements IView {
private _element: HTMLElement = document.createElement('div');
get element(): HTMLElement { this._onDidGetElement.fire(); return this._element; }
private _onDidGetElement = new Emitter<void>();
private readonly _onDidGetElement = new Emitter<void>();
readonly onDidGetElement = this._onDidGetElement.event;
private _width = 0;
@@ -39,10 +39,10 @@ export class TestView implements IView {
get size(): [number, number] { return [this.width, this.height]; }
private _onDidLayout = new Emitter<{ width: number; height: number; }>();
private readonly _onDidLayout = new Emitter<{ width: number; height: number; }>();
readonly onDidLayout: Event<{ width: number; height: number; }> = this._onDidLayout.event;
private _onDidFocus = new Emitter<void>();
private readonly _onDidFocus = new Emitter<void>();
readonly onDidFocus: Event<void> = this._onDidFocus.event;
constructor(

View File

@@ -10,7 +10,7 @@ import { Sash, SashState } from 'vs/base/browser/ui/sash/sash';
class TestView implements IView {
private _onDidChange = new Emitter<number | undefined>();
private readonly _onDidChange = new Emitter<number | undefined>();
readonly onDidChange = this._onDidChange.event;
get minimumSize(): number { return this._minimumSize; }
@@ -22,17 +22,17 @@ class TestView implements IView {
private _element: HTMLElement = document.createElement('div');
get element(): HTMLElement { this._onDidGetElement.fire(); return this._element; }
private _onDidGetElement = new Emitter<void>();
private readonly _onDidGetElement = new Emitter<void>();
readonly onDidGetElement = this._onDidGetElement.event;
private _size = 0;
get size(): number { return this._size; }
private _orthogonalSize: number | undefined = 0;
get orthogonalSize(): number | undefined { return this._orthogonalSize; }
private _onDidLayout = new Emitter<{ size: number; orthogonalSize: number | undefined }>();
private readonly _onDidLayout = new Emitter<{ size: number; orthogonalSize: number | undefined }>();
readonly onDidLayout = this._onDidLayout.event;
private _onDidFocus = new Emitter<void>();
private readonly _onDidFocus = new Emitter<void>();
readonly onDidFocus = this._onDidFocus.event;
constructor(

View File

@@ -690,4 +690,38 @@ suite('IndexTreeModel', function () {
assert.deepEqual(model.getNodeLocation(list[3]), [0, 5]);
});
});
test('refilter with filtered out nodes', function () {
const list: ITreeNode<string>[] = [];
let query = new RegExp('');
const filter = new class implements ITreeFilter<string> {
filter(element: string): boolean {
return query.test(element);
}
};
const model = new IndexTreeModel<string>('test', toSpliceable(list), 'root', { filter });
model.splice([0], 0, Iterator.fromArray([
{ element: 'silver' },
{ element: 'gold' },
{ element: 'platinum' }
]));
assert.deepEqual(toArray(list), ['silver', 'gold', 'platinum']);
query = /platinum/;
model.refilter();
assert.deepEqual(toArray(list), ['platinum']);
model.splice([0], Number.POSITIVE_INFINITY, Iterator.fromArray([
{ element: 'silver' },
{ element: 'gold' },
{ element: 'platinum' }
]));
assert.deepEqual(toArray(list), ['platinum']);
model.refilter();
assert.deepEqual(toArray(list), ['platinum']);
});
});

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { memoize } from 'vs/base/common/decorators';
import { memoize, createMemoizer } from 'vs/base/common/decorators';
suite('Decorators', () => {
test('memoize should memoize methods', () => {
@@ -125,4 +125,24 @@ suite('Decorators', () => {
assert.equal(foo.answer, 42);
}
});
test('memoize clear', () => {
const memoizer = createMemoizer();
let counter = 0;
class Foo {
@memoizer
get answer() { return ++counter; }
}
const foo = new Foo();
assert.equal(foo.answer, 1);
assert.equal(foo.answer, 1);
memoizer.clear();
assert.equal(foo.answer, 2);
assert.equal(foo.answer, 2);
memoizer.clear();
assert.equal(foo.answer, 3);
assert.equal(foo.answer, 3);
assert.equal(foo.answer, 3);
});
});

View File

@@ -25,7 +25,7 @@ namespace Samples {
export class Document3 {
private _onDidChange = new Emitter<string>();
private readonly _onDidChange = new Emitter<string>();
onDidChange: Event<string> = this._onDidChange.event;

View File

@@ -0,0 +1,49 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as assert from 'assert';
import { ResourceTree, IBranchNode, ILeafNode } from 'vs/base/common/resourceTree';
import { URI } from 'vs/base/common/uri';
suite('ResourceTree', function () {
test('ctor', function () {
const tree = new ResourceTree<string, null>(null);
assert(ResourceTree.isBranchNode(tree.root));
assert.equal(tree.root.size, 0);
});
test('simple', function () {
const tree = new ResourceTree<string, null>(null);
tree.add(URI.file('/foo/bar.txt'), 'bar contents');
assert(ResourceTree.isBranchNode(tree.root));
assert.equal(tree.root.size, 1);
let foo = tree.root.get('foo') as IBranchNode<string, null>;
assert(foo);
assert(ResourceTree.isBranchNode(foo));
assert.equal(foo.size, 1);
let bar = foo.get('bar.txt') as ILeafNode<string, null>;
assert(bar);
assert(!ResourceTree.isBranchNode(bar));
assert.equal(bar.element, 'bar contents');
tree.add(URI.file('/hello.txt'), 'hello contents');
assert.equal(tree.root.size, 2);
let hello = tree.root.get('hello.txt') as ILeafNode<string, null>;
assert(hello);
assert(!ResourceTree.isBranchNode(hello));
assert.equal(hello.element, 'hello contents');
tree.delete(URI.file('/foo/bar.txt'));
assert.equal(tree.root.size, 1);
hello = tree.root.get('hello.txt') as ILeafNode<string, null>;
assert(hello);
assert(!ResourceTree.isBranchNode(hello));
assert.equal(hello.element, 'hello contents');
});
});

View File

@@ -209,4 +209,10 @@ if (options.workspaceUri) {
options.workspaceUri = URI.revive(options.workspaceUri);
}
if (Array.isArray(options.staticExtensions)) {
options.staticExtensions.forEach(extension => {
extension.extensionLocation = URI.revive(extension.extensionLocation);
});
}
create(document.body, options);

View File

@@ -303,7 +303,7 @@ export class IssueReporter extends Disposable {
const loggerClient = new LoggerChannelClient(mainProcessService.getChannel('logger'));
this.logService = new FollowerLogService(loggerClient, logService);
const sharedProcess = (<IWindowsService>serviceCollection.get(IWindowsService)).whenSharedProcessReady()
const sharedProcess = mainProcessService.getChannel('sharedProcess').call('whenSharedProcessReady')
.then(() => connectNet(this.environmentService.sharedIPCHandle, `window:${configuration.windowId}`));
const instantiationService = new InstantiationService(serviceCollection, true);

View File

@@ -51,7 +51,7 @@ import { IFileService } from 'vs/platform/files/common/files';
import { DiskFileSystemProvider } from 'vs/platform/files/electron-browser/diskFileSystemProvider';
import { Schemas } from 'vs/base/common/network';
import { IProductService } from 'vs/platform/product/common/productService';
import { IUserDataSyncService, IUserDataSyncStoreService, ISettingsMergeService } from 'vs/platform/userDataSync/common/userDataSync';
import { IUserDataSyncService, IUserDataSyncStoreService, ISettingsMergeService, registerConfiguration } from 'vs/platform/userDataSync/common/userDataSync';
import { UserDataSyncService, UserDataAutoSync } from 'vs/platform/userDataSync/common/userDataSyncService';
import { UserDataSyncStoreService } from 'vs/platform/userDataSync/common/userDataSyncStoreService';
import { UserDataSyncChannel } from 'vs/platform/userDataSync/common/userDataSyncIpc';
@@ -122,11 +122,6 @@ async function main(server: Server, initData: ISharedProcessInitData, configurat
const windowsService = new WindowsService(mainProcessService);
services.set(IWindowsService, windowsService);
const activeWindowManager = new ActiveWindowManager(windowsService);
const activeWindowRouter = new StaticRouter(ctx => activeWindowManager.getActiveClientId().then(id => ctx === id));
const settingsMergeChannel = server.getChannel('settingsMerge', activeWindowRouter);
services.set(ISettingsMergeService, new SettingsMergeChannelClient(settingsMergeChannel));
// Files
const fileService = new FileService(logService);
services.set(IFileService, fileService);
@@ -173,8 +168,15 @@ async function main(server: Server, initData: ISharedProcessInitData, configurat
services.set(IExtensionGalleryService, new SyncDescriptor(ExtensionGalleryService));
services.set(ILocalizationsService, new SyncDescriptor(LocalizationsService));
services.set(IDiagnosticsService, new SyncDescriptor(DiagnosticsService));
// User Data Sync Contributions
const activeWindowManager = new ActiveWindowManager(windowsService);
const activeWindowRouter = new StaticRouter(ctx => activeWindowManager.getActiveClientId().then(id => ctx === id));
const settingsMergeChannel = server.getChannel('settingsMerge', activeWindowRouter);
services.set(ISettingsMergeService, new SettingsMergeChannelClient(settingsMergeChannel));
services.set(IUserDataSyncStoreService, new SyncDescriptor(UserDataSyncStoreService));
services.set(IUserDataSyncService, new SyncDescriptor(UserDataSyncService));
registerConfiguration();
const instantiationService2 = instantiationService.createChild(services);

View File

@@ -3,12 +3,12 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { app, ipcMain as ipc, systemPreferences, shell, Event, contentTracing, protocol, powerMonitor } from 'electron';
import { app, ipcMain as ipc, systemPreferences, shell, Event, contentTracing, protocol, powerMonitor, IpcMainEvent } from 'electron';
import { IProcessEnvironment, isWindows, isMacintosh } from 'vs/base/common/platform';
import { WindowsManager } from 'vs/code/electron-main/windows';
import { IWindowsService, OpenContext, ActiveWindowManager, IURIToOpen } from 'vs/platform/windows/common/windows';
import { WindowsChannel } from 'vs/platform/windows/common/windowsIpc';
import { WindowsService } from 'vs/platform/windows/electron-main/windowsService';
import { LegacyWindowsMainService } from 'vs/platform/windows/electron-main/legacyWindowsMainService';
import { ILifecycleMainService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
import { getShellEnvironment } from 'vs/code/node/shellEnv';
import { IUpdateService } from 'vs/platform/update/common/update';
@@ -17,7 +17,7 @@ import { Server as ElectronIPCServer } from 'vs/base/parts/ipc/electron-main/ipc
import { Client } from 'vs/base/parts/ipc/common/ipc.net';
import { Server, connect } from 'vs/base/parts/ipc/node/ipc.net';
import { SharedProcess } from 'vs/code/electron-main/sharedProcess';
import { LaunchMainService, LaunchChannel, ILaunchMainService } from 'vs/platform/launch/electron-main/launchService';
import { LaunchMainService, LaunchChannel, ILaunchMainService } from 'vs/platform/launch/electron-main/launchMainService';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
@@ -53,7 +53,6 @@ import { ElectronURLListener } from 'vs/platform/url/electron-main/electronUrlLi
import { serve as serveDriver } from 'vs/platform/driver/electron-main/driver';
import { IMenubarService } from 'vs/platform/menubar/node/menubar';
import { MenubarMainService } from 'vs/platform/menubar/electron-main/menubarMainService';
import { MenubarChannel } from 'vs/platform/menubar/node/menubarIpc';
import { RunOnceScheduler } from 'vs/base/common/async';
import { registerContextMenuListener } from 'vs/base/parts/contextmenu/electron-main/contextmenu';
import { homedir } from 'os';
@@ -78,6 +77,7 @@ import { DiskFileSystemProvider } from 'vs/platform/files/node/diskFileSystemPro
import { ExtensionHostDebugBroadcastChannel } from 'vs/platform/debug/common/extensionHostDebugIpc';
import { IElectronService } from 'vs/platform/electron/node/electron';
import { ElectronMainService } from 'vs/platform/electron/electron-main/electronMainService';
import { ISharedProcessMainService, SharedProcessMainService } from 'vs/platform/ipc/electron-main/sharedProcessMainService';
export class CodeApplication extends Disposable {
@@ -125,7 +125,7 @@ export class CodeApplication extends Disposable {
// Mac only event: open new window when we get activated
if (!hasVisibleWindows && this.windowsMainService) {
this.windowsMainService.openNewWindow(OpenContext.DOCK);
this.windowsMainService.openEmptyWindow(OpenContext.DOCK);
}
});
@@ -165,8 +165,8 @@ export class CodeApplication extends Disposable {
event.preventDefault();
});
app.on('web-contents-created', (_event: Electron.Event, contents) => {
contents.on('will-attach-webview', (event: Electron.Event, webPreferences, params) => {
app.on('web-contents-created', (_event: Event, contents) => {
contents.on('will-attach-webview', (event: Event, webPreferences, params) => {
const isValidWebviewSource = (source: string): boolean => {
if (!source) {
@@ -247,7 +247,7 @@ export class CodeApplication extends Disposable {
app.on('new-window-for-tab', () => {
if (this.windowsMainService) {
this.windowsMainService.openNewWindow(OpenContext.DESKTOP); //macOS native tab "+" button
this.windowsMainService.openEmptyWindow(OpenContext.DESKTOP); //macOS native tab "+" button
}
});
@@ -258,7 +258,7 @@ export class CodeApplication extends Disposable {
this.lifecycleMainService.kill(code);
});
ipc.on('vscode:fetchShellEnv', async (event: Electron.IpcMainEvent) => {
ipc.on('vscode:fetchShellEnv', async (event: IpcMainEvent) => {
const webContents = event.sender;
try {
@@ -275,10 +275,10 @@ export class CodeApplication extends Disposable {
}
});
ipc.on('vscode:toggleDevTools', (event: Electron.IpcMainEvent) => event.sender.toggleDevTools());
ipc.on('vscode:openDevTools', (event: Electron.IpcMainEvent) => event.sender.openDevTools());
ipc.on('vscode:toggleDevTools', (event: IpcMainEvent) => event.sender.toggleDevTools());
ipc.on('vscode:openDevTools', (event: IpcMainEvent) => event.sender.openDevTools());
ipc.on('vscode:reloadWindow', (event: Electron.IpcMainEvent) => event.sender.reload());
ipc.on('vscode:reloadWindow', (event: IpcMainEvent) => event.sender.reload());
// Some listeners after window opened
(async () => {
@@ -449,7 +449,8 @@ export class CodeApplication extends Disposable {
}
services.set(IWindowsMainService, new SyncDescriptor(WindowsManager, [machineId, this.userEnv]));
services.set(IWindowsService, new SyncDescriptor(WindowsService, [sharedProcess]));
services.set(ISharedProcessMainService, new SyncDescriptor(SharedProcessMainService, [sharedProcess]));
services.set(IWindowsService, new SyncDescriptor(LegacyWindowsMainService));
services.set(ILaunchMainService, new SyncDescriptor(LaunchMainService));
const diagnosticsChannel = getDelayedChannel(sharedProcessClient.then(client => client.getChannel('diagnostics')));
@@ -546,8 +547,12 @@ export class CodeApplication extends Disposable {
const electronChannel = new SimpleServiceProxyChannel(electronService);
electronIpcServer.registerChannel('electron', electronChannel);
const sharedProcessMainService = accessor.get(ISharedProcessMainService);
const sharedProcessChannel = new SimpleServiceProxyChannel(sharedProcessMainService);
electronIpcServer.registerChannel('sharedProcess', sharedProcessChannel);
const workspacesMainService = accessor.get(IWorkspacesMainService);
const workspacesChannel = new WorkspacesChannel(workspacesMainService);
const workspacesChannel = new WorkspacesChannel(workspacesMainService, accessor.get(IWindowsMainService));
electronIpcServer.registerChannel('workspaces', workspacesChannel);
const windowsService = accessor.get(IWindowsService);
@@ -556,7 +561,7 @@ export class CodeApplication extends Disposable {
sharedProcessClient.then(client => client.registerChannel('windows', windowsChannel));
const menubarService = accessor.get(IMenubarService);
const menubarChannel = new MenubarChannel(menubarService);
const menubarChannel = new SimpleServiceProxyChannel(menubarService);
electronIpcServer.registerChannel('menubar', menubarChannel);
const urlService = accessor.get(IURLService);

View File

@@ -7,13 +7,13 @@ import { localize } from 'vs/nls';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IWindowsMainService } from 'vs/platform/windows/electron-main/windows';
import { Event } from 'vs/base/common/event';
import { BrowserWindow, app } from 'electron';
import { BrowserWindow, app, AuthInfo, WebContents, Event as ElectronEvent } from 'electron';
type LoginEvent = {
event: Electron.Event;
webContents: Electron.WebContents;
req: Electron.Request;
authInfo: Electron.AuthInfo;
event: ElectronEvent;
webContents: WebContents;
req: Request;
authInfo: AuthInfo;
cb: (username: string, password: string) => void;
};
@@ -93,4 +93,4 @@ export class ProxyAuthHandler {
dispose(): void {
this.disposables = dispose(this.disposables);
}
}
}

View File

@@ -14,7 +14,7 @@ import { mkdirp } from 'vs/base/node/pfs';
import { validatePaths } from 'vs/code/node/paths';
import { LifecycleMainService, ILifecycleMainService } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
import { Server, serve, connect } from 'vs/base/parts/ipc/node/ipc.net';
import { LaunchChannelClient } from 'vs/platform/launch/electron-main/launchService';
import { LaunchChannelClient } from 'vs/platform/launch/electron-main/launchMainService';
import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { InstantiationService } from 'vs/platform/instantiation/common/instantiationService';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';

View File

@@ -18,7 +18,7 @@ export class SharedProcess implements ISharedProcess {
private barrier = new Barrier();
private window: Electron.BrowserWindow | null = null;
private window: BrowserWindow | null = null;
constructor(
private readonly machineId: string,

View File

@@ -7,7 +7,7 @@ import * as path from 'vs/base/common/path';
import * as objects from 'vs/base/common/objects';
import * as nls from 'vs/nls';
import { URI } from 'vs/base/common/uri';
import { screen, BrowserWindow, systemPreferences, app, TouchBar, nativeImage, Rectangle, Display } from 'electron';
import { screen, BrowserWindow, systemPreferences, app, TouchBar, nativeImage, Rectangle, Display, TouchBarSegmentedControl, NativeImage, BrowserWindowConstructorOptions, SegmentedControlSegment } from 'electron';
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
import { ILogService } from 'vs/platform/log/common/log';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
@@ -44,7 +44,7 @@ export const defaultWindowState = function (mode = WindowMode.Normal): IWindowSt
};
};
interface ITouchBarSegment extends Electron.SegmentedControlSegment {
interface ITouchBarSegment extends SegmentedControlSegment {
id: string;
}
@@ -58,7 +58,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
private hiddenTitleBarStyle: boolean;
private showTimeoutHandle: NodeJS.Timeout;
private _id: number;
private _win: Electron.BrowserWindow;
private _win: BrowserWindow;
private _lastFocusTime: number;
private _readyState: ReadyState;
private windowState: IWindowState;
@@ -72,7 +72,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
private marketplaceHeadersPromise: Promise<object>;
private readonly touchBarGroups: Electron.TouchBarSegmentedControl[];
private readonly touchBarGroups: TouchBarSegmentedControl[];
constructor(
config: IWindowCreationOptions,
@@ -116,7 +116,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
// in case we are maximized or fullscreen, only show later after the call to maximize/fullscreen (see below)
const isFullscreenOrMaximized = (this.windowState.mode === WindowMode.Maximized || this.windowState.mode === WindowMode.Fullscreen);
const options: Electron.BrowserWindowConstructorOptions = {
const options: BrowserWindowConstructorOptions = {
width: this.windowState.width,
height: this.windowState.height,
x: this.windowState.x,
@@ -231,7 +231,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
return this._id;
}
get win(): Electron.BrowserWindow {
get win(): BrowserWindow {
return this._win;
}
@@ -421,7 +421,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
});
// Window Failed to load
this._win.webContents.on('did-fail-load', (event: Electron.Event, errorCode: number, errorDescription: string, validatedURL: string, isMainFrame: boolean) => {
this._win.webContents.on('did-fail-load', (event: Event, errorCode: number, errorDescription: string, validatedURL: string, isMainFrame: boolean) => {
this.logService.warn('[electron event]: fail to load, ', errorDescription);
});
@@ -653,7 +653,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
// only consider non-minimized window states
if (mode === WindowMode.Normal || mode === WindowMode.Maximized) {
let bounds: Electron.Rectangle;
let bounds: Rectangle;
if (mode === WindowMode.Normal) {
bounds = this.getBounds();
} else {
@@ -778,7 +778,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
return undefined;
}
getBounds(): Electron.Rectangle {
getBounds(): Rectangle {
const pos = this._win.getPosition();
const dimension = this._win.getSize();
@@ -908,7 +908,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
}
}
onWindowTitleDoubleClick(): void {
handleTitleDoubleClick(): void {
// Respect system settings on mac with regards to title click on windows title
if (isMacintosh) {
@@ -988,7 +988,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
this._win.setTouchBar(new TouchBar({ items: this.touchBarGroups }));
}
private createTouchBarGroup(items: ISerializableCommandAction[] = []): Electron.TouchBarSegmentedControl {
private createTouchBarGroup(items: ISerializableCommandAction[] = []): TouchBarSegmentedControl {
// Group Segments
const segments = this.createTouchBarGroupSegments(items);
@@ -1008,7 +1008,7 @@ export class CodeWindow extends Disposable implements ICodeWindow {
private createTouchBarGroupSegments(items: ISerializableCommandAction[] = []): ITouchBarSegment[] {
const segments: ITouchBarSegment[] = items.map(item => {
let icon: Electron.NativeImage | undefined;
let icon: NativeImage | undefined;
if (item.iconLocation && item.iconLocation.dark.scheme === 'file') {
icon = nativeImage.createFromPath(URI.revive(item.iconLocation.dark).fsPath);
if (icon.isEmpty()) {

View File

@@ -13,12 +13,12 @@ import { IEmptyWindowBackupInfo } from 'vs/platform/backup/node/backup';
import { IEnvironmentService, ParsedArgs } from 'vs/platform/environment/common/environment';
import { IStateService } from 'vs/platform/state/common/state';
import { CodeWindow, defaultWindowState } from 'vs/code/electron-main/window';
import { ipcMain as ipc, screen, BrowserWindow, dialog, systemPreferences, FileFilter } from 'electron';
import { ipcMain as ipc, screen, BrowserWindow, dialog, systemPreferences, FileFilter, shell, MessageBoxReturnValue, MessageBoxOptions, SaveDialogOptions, SaveDialogReturnValue, OpenDialogOptions, OpenDialogReturnValue, Display } from 'electron';
import { parseLineAndColumnAware } from 'vs/code/node/paths';
import { ILifecycleMainService, UnloadReason, LifecycleMainService, LifecycleMainPhase } from 'vs/platform/lifecycle/electron-main/lifecycleMainService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ILogService } from 'vs/platform/log/common/log';
import { IWindowSettings, OpenContext, IPath, IWindowConfiguration, INativeOpenDialogOptions, IPathsToWaitFor, IEnterWorkspaceResult, IMessageBoxResult, INewWindowOptions, IURIToOpen, isFileToOpen, isWorkspaceToOpen, isFolderToOpen } from 'vs/platform/windows/common/windows';
import { IWindowSettings, OpenContext, IPath, IWindowConfiguration, INativeOpenDialogOptions, IPathsToWaitFor, IEnterWorkspaceResult, IURIToOpen, isFileToOpen, isWorkspaceToOpen, isFolderToOpen } from 'vs/platform/windows/common/windows';
import { getLastActiveWindow, findBestWindowOrFolderForFile, findWindowOnWorkspace, findWindowOnExtensionDevelopmentPath, findWindowOnWorkspaceOrFolderUri } from 'vs/code/node/windowsFinder';
import { Event as CommonEvent, Emitter } from 'vs/base/common/event';
import product from 'vs/platform/product/common/product';
@@ -197,9 +197,8 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
@IInstantiationService private readonly instantiationService: IInstantiationService
) {
super();
const windowsStateStoreData = this.stateService.getItem<WindowsStateStorageData>(WindowsManager.windowsStateStorageKey);
this.windowsState = restoreWindowsState(windowsStateStoreData);
this.windowsState = restoreWindowsState(this.stateService.getItem<WindowsStateStorageData>(WindowsManager.windowsStateStorageKey));
if (!Array.isArray(this.windowsState.openedWindows)) {
this.windowsState.openedWindows = [];
}
@@ -227,7 +226,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
private registerListeners(): void {
// React to workbench ready events from windows
ipc.on('vscode:workbenchReady', (event: Electron.Event, windowId: number) => {
ipc.on('vscode:workbenchReady', (event: Event, windowId: number) => {
this.logService.trace('IPC#vscode-workbenchReady');
const win = this.getWindowById(windowId);
@@ -381,6 +380,12 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
};
}
async openExternal(url: string): Promise<boolean> {
shell.openExternal(url);
return true;
}
open(openConfig: IOpenConfiguration): ICodeWindow[] {
this.logService.trace('windowsManager#open');
openConfig = this.validateOpenConfig(openConfig);
@@ -867,7 +872,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
message = localize('uriInvalidTitle', "URI can not be opened");
detail = localize('uriInvalidDetail', "The URI '{0}' is not valid and can not be opened.", uri.toString());
}
const options: Electron.MessageBoxOptions = {
const options: MessageBoxOptions = {
title: product.nameLong,
type: 'info',
buttons: [localize('ok', "OK")],
@@ -1468,7 +1473,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
//
// We want the new window to open on the same display that the last active one is in
let displayToUse: Electron.Display | undefined;
let displayToUse: Display | undefined;
const displays = screen.getAllDisplays();
// Single Display
@@ -1605,13 +1610,13 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
return getLastActiveWindow(WindowsManager.WINDOWS.filter(window => window.remoteAuthority === remoteAuthority));
}
openNewWindow(context: OpenContext, options?: INewWindowOptions): ICodeWindow[] {
openEmptyWindow(context: OpenContext, options?: { reuse?: boolean, remoteAuthority?: string }): ICodeWindow[] {
let cli = this.environmentService.args;
const remote = options && options.remoteAuthority || undefined;
const remote = options && options.remoteAuthority;
if (cli && (cli.remote !== remote)) {
cli = { ...cli, remote };
}
const forceReuseWindow = options && options.reuseWindow;
const forceReuseWindow = options && options.reuse;
const forceNewWindow = !forceReuseWindow;
return this.open({ context, cli, forceEmpty: true, forceNewWindow, forceReuseWindow });
}
@@ -1665,11 +1670,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
getWindowById(windowId: number): ICodeWindow | undefined {
const res = WindowsManager.WINDOWS.filter(window => window.id === windowId);
if (res && res.length === 1) {
return res[0];
}
return undefined;
return arrays.firstOrDefault(res);
}
getWindows(): ICodeWindow[] {
@@ -1714,9 +1715,9 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
return; // Return early if the window has been going down already
}
if (result.button === 0) {
if (result.response === 0) {
window.reload();
} else if (result.button === 2) {
} else if (result.response === 2) {
this.onBeforeWindowClose(window); // 'close' event will not be fired on destroy(), so run it manually
window.win.destroy(); // make sure to destroy the window as it is unresponsive
}
@@ -1737,9 +1738,9 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
return; // Return early if the window has been going down already
}
if (result.button === 0) {
if (result.response === 0) {
window.reload();
} else if (result.button === 1) {
} else if (result.response === 1) {
this.onBeforeWindowClose(window); // 'close' event will not be fired on destroy(), so run it manually
window.win.destroy(); // make sure to destroy the window as it has crashed
}
@@ -1761,7 +1762,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
this._onWindowClose.fire(win.id);
}
async pickFileFolderAndOpen(options: INativeOpenDialogOptions): Promise<void> {
async pickFileFolderAndOpen(options: INativeOpenDialogOptions, win?: ICodeWindow): Promise<void> {
const title = localize('open', "Open");
const paths = await this.dialogs.pick({ ...options, pickFolders: true, pickFiles: true, title });
if (paths) {
@@ -1773,7 +1774,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
}));
this.open({
context: OpenContext.DIALOG,
contextWindowId: options.windowId,
contextWindowId: win ? win.id : undefined,
cli: this.environmentService.args,
urisToOpen,
forceNewWindow: options.forceNewWindow
@@ -1781,14 +1782,14 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
}
}
async pickFolderAndOpen(options: INativeOpenDialogOptions): Promise<void> {
async pickFolderAndOpen(options: INativeOpenDialogOptions, win?: ICodeWindow): Promise<void> {
const title = localize('openFolder', "Open Folder");
const paths = await this.dialogs.pick({ ...options, pickFolders: true, title });
if (paths) {
this.sendPickerTelemetry(paths, options.telemetryEventName || 'openFolder', options.telemetryExtraData);
this.open({
context: OpenContext.DIALOG,
contextWindowId: options.windowId,
contextWindowId: win ? win.id : undefined,
cli: this.environmentService.args,
urisToOpen: paths.map(path => ({ folderUri: URI.file(path) })),
forceNewWindow: options.forceNewWindow
@@ -1796,14 +1797,14 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
}
}
async pickFileAndOpen(options: INativeOpenDialogOptions): Promise<void> {
async pickFileAndOpen(options: INativeOpenDialogOptions, win?: ICodeWindow): Promise<void> {
const title = localize('openFile', "Open File");
const paths = await this.dialogs.pick({ ...options, pickFiles: true, title });
if (paths) {
this.sendPickerTelemetry(paths, options.telemetryEventName || 'openFile', options.telemetryExtraData);
this.open({
context: OpenContext.DIALOG,
contextWindowId: options.windowId,
contextWindowId: win ? win.id : undefined,
cli: this.environmentService.args,
urisToOpen: paths.map(path => ({ fileUri: URI.file(path) })),
forceNewWindow: options.forceNewWindow
@@ -1811,7 +1812,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
}
}
async pickWorkspaceAndOpen(options: INativeOpenDialogOptions): Promise<void> {
async pickWorkspaceAndOpen(options: INativeOpenDialogOptions, win?: ICodeWindow): Promise<void> {
const title = localize('openWorkspaceTitle', "Open Workspace");
const buttonLabel = mnemonicButtonLabel(localize({ key: 'openWorkspace', comment: ['&& denotes a mnemonic'] }, "&&Open"));
const filters = WORKSPACE_FILTER;
@@ -1820,7 +1821,7 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
this.sendPickerTelemetry(paths, options.telemetryEventName || 'openWorkspace', options.telemetryExtraData);
this.open({
context: OpenContext.DIALOG,
contextWindowId: options.windowId,
contextWindowId: win ? win.id : undefined,
cli: this.environmentService.args,
urisToOpen: paths.map(path => ({ workspaceUri: URI.file(path) })),
forceNewWindow: options.forceNewWindow
@@ -1842,15 +1843,15 @@ export class WindowsManager extends Disposable implements IWindowsMainService {
});
}
showMessageBox(options: Electron.MessageBoxOptions, win?: ICodeWindow): Promise<IMessageBoxResult> {
showMessageBox(options: MessageBoxOptions, win?: ICodeWindow): Promise<MessageBoxReturnValue> {
return this.dialogs.showMessageBox(options, win);
}
showSaveDialog(options: Electron.SaveDialogOptions, win?: ICodeWindow): Promise<string> {
showSaveDialog(options: SaveDialogOptions, win?: ICodeWindow): Promise<SaveDialogReturnValue> {
return this.dialogs.showSaveDialog(options, win);
}
showOpenDialog(options: Electron.OpenDialogOptions, win?: ICodeWindow): Promise<string[]> {
showOpenDialog(options: OpenDialogOptions, win?: ICodeWindow): Promise<OpenDialogReturnValue> {
return this.dialogs.showOpenDialog(options, win);
}
@@ -1897,10 +1898,10 @@ class Dialogs {
this.noWindowDialogQueue = new Queue<void>();
}
async pick(options: IInternalNativeOpenDialogOptions): Promise<string[] | undefined> {
async pick(options: IInternalNativeOpenDialogOptions, win?: ICodeWindow): Promise<string[] | undefined> {
// Ensure dialog options
const dialogOptions: Electron.OpenDialogOptions = {
const dialogOptions: OpenDialogOptions = {
title: options.title,
buttonLabel: options.buttonLabel,
filters: options.filters
@@ -1928,15 +1929,15 @@ class Dialogs {
}
// Show Dialog
const focusedWindow = (typeof options.windowId === 'number' ? this.windowsMainService.getWindowById(options.windowId) : undefined) || this.windowsMainService.getFocusedWindow();
const windowToUse = win || this.windowsMainService.getFocusedWindow();
const paths = await this.showOpenDialog(dialogOptions, focusedWindow);
if (paths && paths.length > 0) {
const result = await this.showOpenDialog(dialogOptions, windowToUse);
if (result && result.filePaths && result.filePaths.length > 0) {
// Remember path in storage for next time
this.stateService.setItem(Dialogs.workingDirPickerStorageKey, dirname(paths[0]));
this.stateService.setItem(Dialogs.workingDirPickerStorageKey, dirname(result.filePaths[0]));
return paths;
return result.filePaths;
}
return undefined; // {{SQL CARBON EDIT}} @anthonydresser strict-null-check
@@ -1956,20 +1957,17 @@ class Dialogs {
return windowDialogQueue;
}
showMessageBox(options: Electron.MessageBoxOptions, window?: ICodeWindow): Promise<IMessageBoxResult> {
showMessageBox(options: MessageBoxOptions, window?: ICodeWindow): Promise<MessageBoxReturnValue> {
return this.getDialogQueue(window).queue(async () => {
let result: Electron.MessageBoxReturnValue;
if (window) {
result = await dialog.showMessageBox(window.win, options);
} else {
result = await dialog.showMessageBox(options);
return dialog.showMessageBox(window.win, options);
}
return { button: result.response, checkboxChecked: result.checkboxChecked };
return dialog.showMessageBox(options);
});
}
showSaveDialog(options: Electron.SaveDialogOptions, window?: ICodeWindow): Promise<string> {
showSaveDialog(options: SaveDialogOptions, window?: ICodeWindow): Promise<SaveDialogReturnValue> {
function normalizePath(path: string | undefined): string | undefined {
if (path && isMacintosh) {
@@ -1980,18 +1978,20 @@ class Dialogs {
}
return this.getDialogQueue(window).queue(async () => {
let result: Electron.SaveDialogReturnValue;
let result: SaveDialogReturnValue;
if (window) {
result = await dialog.showSaveDialog(window.win, options);
} else {
result = await dialog.showSaveDialog(options);
}
return normalizePath(result.filePath);
result.filePath = normalizePath(result.filePath);
return result;
});
}
showOpenDialog(options: Electron.OpenDialogOptions, window?: ICodeWindow): Promise<string[]> {
showOpenDialog(options: OpenDialogOptions, window?: ICodeWindow): Promise<OpenDialogReturnValue> {
function normalizePaths(paths: string[] | undefined): string[] | undefined {
if (paths && paths.length > 0 && isMacintosh) {
@@ -2012,14 +2012,16 @@ class Dialogs {
}
// Show dialog
let result: Electron.OpenDialogReturnValue;
let result: OpenDialogReturnValue;
if (window) {
result = await dialog.showOpenDialog(window.win, options);
} else {
result = await dialog.showOpenDialog(options);
}
return normalizePaths(result.filePaths);
result.filePaths = normalizePaths(result.filePaths);
return result;
});
}
}
@@ -2056,7 +2058,7 @@ class WorkspacesManager {
// Prevent overwriting a workspace that is currently opened in another window
if (findWindowOnWorkspace(this.windowsMainService.getWindows(), getWorkspaceIdentifier(path))) {
const options: Electron.MessageBoxOptions = {
const options: MessageBoxOptions = {
title: product.nameLong,
type: 'info',
buttons: [localize('ok', "OK")],

View File

@@ -70,8 +70,8 @@ export abstract class AbstractCodeEditorService extends Disposable implements IC
return Object.keys(this._diffEditors).map(id => this._diffEditors[id]);
}
getFocusedCodeEditor(): ICodeEditor | null {
let editorWithWidgetFocus: ICodeEditor | null = null;
getFocusedCodeEditor(): ICodeEditor | undefined {
let editorWithWidgetFocus: ICodeEditor | undefined;
const editors = this.listCodeEditors();
for (const editor of editors) {
@@ -124,8 +124,8 @@ export abstract class AbstractCodeEditorService extends Disposable implements IC
delete this._transientWatchers[w.uri];
}
abstract getActiveCodeEditor(): ICodeEditor | null;
abstract openCodeEditor(input: IResourceInput, source: ICodeEditor | null, sideBySide?: boolean): Promise<ICodeEditor | null>;
abstract getActiveCodeEditor(): ICodeEditor | undefined;
abstract openCodeEditor(input: IResourceInput, source: ICodeEditor | undefined, sideBySide?: boolean): Promise<ICodeEditor | undefined>;
}
export class ModelTransientSettingWatcher {

View File

@@ -26,16 +26,17 @@ export interface ICodeEditorService {
addCodeEditor(editor: ICodeEditor): void;
removeCodeEditor(editor: ICodeEditor): void;
listCodeEditors(): ICodeEditor[];
listCodeEditors(): readonly ICodeEditor[];
addDiffEditor(editor: IDiffEditor): void;
removeDiffEditor(editor: IDiffEditor): void;
listDiffEditors(): IDiffEditor[];
listDiffEditors(): readonly IDiffEditor[];
/**
* Returns the current focused code editor (if the focus is in the editor or in an editor widget) or null.
* Returns the current focused code editor (if the focus is in the editor or in an editor widget) or
* `undefined` if none.
*/
getFocusedCodeEditor(): ICodeEditor | null;
getFocusedCodeEditor(): ICodeEditor | undefined;
registerDecorationType(key: string, options: IDecorationRenderOptions, parentTypeKey?: string): void;
removeDecorationType(key: string): void;
@@ -44,6 +45,6 @@ export interface ICodeEditorService {
setTransientModelProperty(model: ITextModel, key: string, value: any): void;
getTransientModelProperty(model: ITextModel, key: string): any;
getActiveCodeEditor(): ICodeEditor | null;
openCodeEditor(input: IResourceInput, source: ICodeEditor | null, sideBySide?: boolean): Promise<ICodeEditor | null>;
getActiveCodeEditor(): ICodeEditor | undefined;
openCodeEditor(input: IResourceInput, source: ICodeEditor | undefined, sideBySide?: boolean): Promise<ICodeEditor | undefined>;
}

View File

@@ -65,8 +65,8 @@ export abstract class CodeEditorServiceImpl extends AbstractCodeEditorService {
return provider.getOptions(this, writable);
}
abstract getActiveCodeEditor(): ICodeEditor | null;
abstract openCodeEditor(input: IResourceInput, source: ICodeEditor | null, sideBySide?: boolean): Promise<ICodeEditor | null>;
abstract getActiveCodeEditor(): ICodeEditor | undefined;
abstract openCodeEditor(input: IResourceInput, source: ICodeEditor | undefined, sideBySide?: boolean): Promise<ICodeEditor | undefined>;
}
interface IModelDecorationOptionsProvider extends IDisposable {

View File

@@ -13,7 +13,7 @@ import { equalsIgnoreCase } from 'vs/base/common/strings';
import { URI } from 'vs/base/common/uri';
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
import { CommandsRegistry, ICommandService } from 'vs/platform/commands/common/commands';
import { IOpener, IOpenerService, IValidator, IExternalUriResolver } from 'vs/platform/opener/common/opener';
import { IOpener, IOpenerService, IValidator, IExternalUriResolver, OpenOptions } from 'vs/platform/opener/common/opener';
export class OpenerService extends Disposable implements IOpenerService {
@@ -45,7 +45,7 @@ export class OpenerService extends Disposable implements IOpenerService {
return { dispose: remove };
}
async open(resource: URI, options?: { openToSide?: boolean, openExternal?: boolean }): Promise<boolean> {
async open(resource: URI, options?: OpenOptions): Promise<boolean> {
// no scheme ?!?
if (!resource.scheme) {
return Promise.resolve(false);
@@ -65,22 +65,33 @@ export class OpenerService extends Disposable implements IOpenerService {
return true;
}
}
// use default openers
return this._doOpen(resource, options);
}
private _doOpen(resource: URI, options?: { openToSide?: boolean, openExternal?: boolean }): Promise<boolean> {
public async resolveExternalUri(resource: URI, options?: { readonly allowTunneling?: boolean }): Promise<{ resolved: URI, dispose(): void }> {
for (const resolver of this._resolvers.toArray()) {
const result = await resolver.resolveExternalUri(resource, options);
if (result) {
return result;
}
}
return { resolved: resource, dispose: () => { } };
}
private _doOpen(resource: URI, options: OpenOptions | undefined): Promise<boolean> {
const { scheme, path, query, fragment } = resource;
if (equalsIgnoreCase(scheme, Schemas.mailto) || (options && options.openExternal)) {
// open default mail application
return this._doOpenExternal(resource);
return this._doOpenExternal(resource, options);
}
if (equalsIgnoreCase(scheme, Schemas.http) || equalsIgnoreCase(scheme, Schemas.https)) {
// open link in default browser
return this._doOpenExternal(resource);
return this._doOpenExternal(resource, options);
} else if (equalsIgnoreCase(scheme, Schemas.command)) {
// run command or bail out if command isn't known
if (!CommandsRegistry.getCommand(path)) {
@@ -124,13 +135,9 @@ export class OpenerService extends Disposable implements IOpenerService {
}
}
private async _doOpenExternal(resource: URI): Promise<boolean> {
for (const resolver of this._resolvers.toArray()) {
resource = await resolver.resolveExternalUri(resource);
}
dom.windowOpenNoOpener(encodeURI(resource.toString(true)));
private async _doOpenExternal(resource: URI, options: OpenOptions | undefined): Promise<boolean> {
const { resolved } = await this.resolveExternalUri(resource, options);
dom.windowOpenNoOpener(encodeURI(resolved.toString(true)));
return Promise.resolve(true);
}

View File

@@ -737,7 +737,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
);
}
public setSelections(ranges: ISelection[], source: string = 'api'): void {
public setSelections(ranges: readonly ISelection[], source: string = 'api'): void {
if (!this._modelData) {
return;
}
@@ -1172,7 +1172,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
}
public hasWidgetFocus(): boolean {
return (this._editorWidgetFocus.getValue() === BooleanEventValue.True);
return this._focusTracker && this._focusTracker.hasFocus();
}
public addContentWidget(widget: editorBrowser.IContentWidget): void {
@@ -1452,13 +1452,8 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
}
const viewOutgoingEvents = new ViewOutgoingEvents(viewModel);
viewOutgoingEvents.onDidGainFocus = () => {
this._editorTextFocus.setValue(true);
// In IE, the focus is not synchronous, so we give it a little help
this._editorWidgetFocus.setValue(true);
};
viewOutgoingEvents.onDidScroll = (e) => this._onDidScrollChange.fire(e);
viewOutgoingEvents.onDidGainFocus = () => this._editorTextFocus.setValue(true);
viewOutgoingEvents.onDidLoseFocus = () => this._editorTextFocus.setValue(false);
viewOutgoingEvents.onContextMenu = (e) => this._onContextMenu.fire(e);
viewOutgoingEvents.onMouseDown = (e) => this._onMouseDown.fire(e);
@@ -1548,10 +1543,6 @@ export class BooleanEventEmitter extends Disposable {
this._value = BooleanEventValue.NotSet;
}
public getValue(): BooleanEventValue {
return this._value;
}
public setValue(_value: boolean) {
const value = (_value ? BooleanEventValue.True : BooleanEventValue.False);
if (this._value === value) {

View File

@@ -728,7 +728,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
this.modifiedEditor.setSelection(something);
}
public setSelections(ranges: ISelection[]): void {
public setSelections(ranges: readonly ISelection[]): void {
this.modifiedEditor.setSelections(ranges);
}

View File

@@ -424,7 +424,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
return this._cursors.getPrimaryCursor().modelState.position;
}
public setSelections(source: string, selections: ISelection[]): void {
public setSelections(source: string, selections: readonly ISelection[]): void {
this.setStates(source, CursorChangeReason.NotSet, CursorState.fromModelSelections(selections));
}

View File

@@ -460,7 +460,7 @@ export class CursorState {
return CursorState.fromModelState(modelState);
}
public static fromModelSelections(modelSelections: ISelection[]): PartialModelCursorState[] {
public static fromModelSelections(modelSelections: readonly ISelection[]): PartialModelCursorState[] {
let states: PartialModelCursorState[] = [];
for (let i = 0, len = modelSelections.length; i < len; i++) {
states[i] = this.fromModelSelection(modelSelections[i]);

View File

@@ -389,7 +389,7 @@ export interface IEditor {
* Set the selections for all the cursors of the editor.
* Cursors will be removed or added, as necessary.
*/
setSelections(selections: ISelection[]): void;
setSelections(selections: readonly ISelection[]): void;
/**
* Scroll vertically as necessary and reveal lines.

View File

@@ -32,9 +32,6 @@ export class LanguageFeatureRegistry<T> {
private readonly _entries: Entry<T>[] = [];
private readonly _onDidChange = new Emitter<number>();
constructor() {
}
get onDidChange(): Event<number> {
return this._onDidChange.event;
}

View File

@@ -11,6 +11,7 @@ import { FrankensteinMode } from 'vs/editor/common/modes/abstractMode';
import { NULL_LANGUAGE_IDENTIFIER } from 'vs/editor/common/modes/nullMode';
import { LanguagesRegistry } from 'vs/editor/common/services/languagesRegistry';
import { ILanguageSelection, IModeService } from 'vs/editor/common/services/modeService';
import { firstOrDefault } from 'vs/base/common/arrays';
class LanguageSelection extends Disposable implements ILanguageSelection {
@@ -96,22 +97,12 @@ export class ModeServiceImpl implements IModeService {
public getModeIdByFilepathOrFirstLine(resource: URI | null, firstLine?: string): string | null {
const modeIds = this._registry.getModeIdsFromFilepathOrFirstLine(resource, firstLine);
if (modeIds.length > 0) {
return modeIds[0];
}
return null;
return firstOrDefault(modeIds, null);
}
public getModeId(commaSeparatedMimetypesOrCommaSeparatedIds: string | undefined): string | null {
const modeIds = this._registry.extractModeIds(commaSeparatedMimetypesOrCommaSeparatedIds);
if (modeIds.length > 0) {
return modeIds[0];
}
return null;
return firstOrDefault(modeIds, null);
}
public getLanguageIdentifier(modeId: string | LanguageId): LanguageIdentifier | null {
@@ -164,12 +155,7 @@ export class ModeServiceImpl implements IModeService {
private _getModeIdByLanguageName(languageName: string): string | null {
const modeIds = this._registry.getModeIdsFromLanguageName(languageName);
if (modeIds.length > 0) {
return modeIds[0];
}
return null;
return firstOrDefault(modeIds, null);
}
private _getOrCreateMode(modeId: string): IMode {

View File

@@ -19,7 +19,7 @@ export class MinimapTokensColorTracker {
private _colors!: RGBA8[];
private _backgroundIsLight!: boolean;
private _onDidChange = new Emitter<void>();
private readonly _onDidChange = new Emitter<void>();
public readonly onDidChange: Event<void> = this._onDidChange.event;
private constructor() {

View File

@@ -244,9 +244,6 @@ export class ViewTokensChangedEvent {
export class ViewThemeChangedEvent {
public readonly type = ViewEventType.ViewThemeChanged;
constructor() {
}
}
export class ViewTokensColorsChangedEvent {
@@ -270,9 +267,6 @@ export class ViewZonesChangedEvent {
export class ViewLanguageConfigurationEvent {
public readonly type = ViewEventType.ViewLanguageConfigurationChanged;
constructor() {
}
}
export type ViewEvent = (

View File

@@ -1401,9 +1401,6 @@ class OverviewRulerDecorations {
readonly result: IOverviewRulerDecorations = Object.create(null);
constructor() {
}
public accept(color: string, startLineNumber: number, endLineNumber: number, lane: number): void {
let prev = this.result[color];

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